From 3b3439c3178648ee3fa1aa082e41028aeb1db2a9 Mon Sep 17 00:00:00 2001 From: op Date: Sun, 28 Jan 2024 17:23:17 +0000 Subject: [PATCH] allow escaping inside quotes RFC5322 allows for escapes using \ inside quotes. Otherwise, headers such as From: "\"Doe, John\"" get mangled as "\"Doe@localhost, John\" since \ would be treated as ordinary character and not the escape for the quote. Bug reported by TobiasEgg on the OpenSMTPD-portable github repository. ok millert@ --- usr.sbin/smtpd/smtp_session.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 94763e6d078..3a99cb4f6b9 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.440 2024/01/20 09:01:03 claudio Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.441 2024/01/28 17:23:17 op Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -489,7 +489,7 @@ header_domain_append_callback(struct smtp_tx *tx, const char *hdr, quote = !quote; if (line[i] == ')' && !escape && !quote && comment) comment--; - if (line[i] == '\\' && !escape && !comment && !quote) + if (line[i] == '\\' && !escape && !comment) escape = 1; else escape = 0; -- 2.20.1