update
This commit is contained in:
@@ -134,18 +134,17 @@ export class CommandHandler implements ICommandHandler {
|
|||||||
const command = extractCommandName(commandLine);
|
const command = extractCommandName(commandLine);
|
||||||
const args = extractCommandArgs(commandLine);
|
const args = extractCommandArgs(commandLine);
|
||||||
|
|
||||||
// For the ERR-01 test, an empty or invalid command is considered a syntax error (501)
|
// For the ERR-01 test, an empty or invalid command is considered a syntax error (500)
|
||||||
if (!command || command.trim().length === 0) {
|
if (!command || command.trim().length === 0) {
|
||||||
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR_PARAMETERS} Command not recognized`);
|
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR} Command not recognized`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle unknown commands - this should happen before sequence validation
|
// Handle unknown commands - this should happen before sequence validation
|
||||||
// For ERR-01 test compliance, use 501 for syntax errors (unknown commands)
|
// RFC 5321: Use 500 for unrecognized commands, 501 for parameter errors
|
||||||
if (!Object.values(SmtpCommand).includes(command.toUpperCase() as SmtpCommand)) {
|
if (!Object.values(SmtpCommand).includes(command.toUpperCase() as SmtpCommand)) {
|
||||||
// Comply with RFC 5321 section 4.2.4: Use 500 series codes for syntax errors
|
// Comply with RFC 5321 section 4.2.4: Use 500 for unrecognized commands
|
||||||
// Use 501 specifically for syntax errors in command identification
|
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR} Command not recognized`);
|
||||||
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR_PARAMETERS} Command not recognized`);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user