This commit is contained in:
Philipp Kunz 2025-05-23 08:52:02 +00:00
parent 53f5e30b23
commit 7d28d23bbd

View File

@ -134,18 +134,17 @@ export class CommandHandler implements ICommandHandler {
const command = extractCommandName(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) {
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR_PARAMETERS} Command not recognized`);
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR} Command not recognized`);
return;
}
// 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)) {
// Comply with RFC 5321 section 4.2.4: Use 500 series codes for syntax errors
// Use 501 specifically for syntax errors in command identification
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR_PARAMETERS} Command not recognized`);
// Comply with RFC 5321 section 4.2.4: Use 500 for unrecognized commands
this.sendResponse(socket, `${SmtpResponseCode.SYNTAX_ERROR} Command not recognized`);
return;
}