commit f71dee6: [Fix] Fix quoted-printable soft newlines bugged case
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Nov 20 15:56:07 UTC 2020
Author: Vsevolod Stakhov
Date: 2020-11-20 15:55:39 +0000
URL: https://github.com/rspamd/rspamd/commit/f71dee6d40be52c69f5a90536e811db8e1f852f1 (HEAD -> master)
[Fix] Fix quoted-printable soft newlines bugged case
---
src/libutil/str_util.c | 12 ++++++++----
test/lua/unit/quoted_printable.lua | 10 ++++++++++
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index 1e7d0b06b..2e1fd6a0d 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -2341,15 +2341,19 @@ decode:
if (c >= '0' && c <= '9') { ret = c - '0'; }
else if (c >= 'A' && c <= 'F') { ret = c - 'A' + 10; }
else if (c >= 'a' && c <= 'f') { ret = c - 'a' + 10; }
- else if (c == '\r' || c == '\n') {
- /* Soft line break */
- while (remain > 0 && (*p == '\r' || *p == '\n')) {
- remain --;
+ else if (c == '\r') {
+ /* Eat one more endline */
+ if (remain > 0 && *p == '\n') {
p ++;
+ remain --;
}
continue;
}
+ else if (c == '\n') {
+ /* Soft line break */
+ continue;
+ }
else {
/* Hack, hack, hack, treat =<garbadge> as =<garbadge> */
if (remain > 0) {
diff --git a/test/lua/unit/quoted_printable.lua b/test/lua/unit/quoted_printable.lua
index cf667f8d4..29df0254d 100644
--- a/test/lua/unit/quoted_printable.lua
+++ b/test/lua/unit/quoted_printable.lua
@@ -102,6 +102,16 @@ context("Quoted-Printable encoding", function()
'Mailscape External Mail Flow Outbound Test=',
'asan found'
},
+ {
+ 'foo=\n\nbar',
+ 'foo\nbar',
+ 'Soft newline followed by hard newline (LF)',
+ },
+ {
+ 'foo=\r\n\r\nbar',
+ 'foo\r\nbar',
+ 'Soft newline followed by hard newline (CRLF)',
+ },
}
for _,c in ipairs(cases) do
More information about the Commits
mailing list