aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/libutil/str_util.c12
-rw-r--r--test/lua/unit/quoted_printable.lua10
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