From f9eedbbff4bd31280acdfc855828fbf0cdfc9410 Mon Sep 17 00:00:00 2001 From: notfresh <1195056983@qq.com> Date: Thu, 22 Jan 2026 11:05:01 +0800 Subject: [PATCH 1/3] fix #1040: append the last crlf if miss for multipart data --- include/crow/multipart.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index 24040c962..a780cab01 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -178,7 +178,10 @@ namespace crow void parse_body(std::string body) { std::string delimiter = dd + boundary; - + if(!body.ends_with(crlf)) + { + body += crlf; + } // TODO(EDev): Exit on error while (body != (crlf)) { From dc1b0df1422ca2ce13aa6c60f18b7881c6034306 Mon Sep 17 00:00:00 2001 From: notfresh <1195056983@qq.com> Date: Thu, 22 Jan 2026 11:42:16 +0800 Subject: [PATCH 2/3] fix #1040: append the last crlf if miss for multipart data with self-implemented end_with --- include/crow/multipart.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index a780cab01..448471365 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -175,10 +175,21 @@ namespace crow return std::string(); } + // cpp17(cpp 20 have) does not have ends_with, so we need to implement it ourselves + bool ends_with(const std::string& str, const std::string& suffix) { + if (suffix.size() > str.size()) return false; + return std::equal(suffix.rbegin(), suffix.rend(), str.rbegin()); + } + + // reload for char* suffix + bool ends_with(const std:: string& str, const char* suffix) { + return ends_with(str, std::string(suffix)); + } + void parse_body(std::string body) { std::string delimiter = dd + boundary; - if(!body.ends_with(crlf)) + if(!ends_with(body, crlf)) { body += crlf; } From 31bdcc92fae92060a8935757e5a0010b9b3fdbdf Mon Sep 17 00:00:00 2001 From: notfresh <1195056983@qq.com> Date: Thu, 22 Jan 2026 11:50:16 +0800 Subject: [PATCH 3/3] fix: keep ends_with simple --- include/crow/multipart.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/crow/multipart.h b/include/crow/multipart.h index 448471365..ae2cdc189 100644 --- a/include/crow/multipart.h +++ b/include/crow/multipart.h @@ -181,11 +181,6 @@ namespace crow return std::equal(suffix.rbegin(), suffix.rend(), str.rbegin()); } - // reload for char* suffix - bool ends_with(const std:: string& str, const char* suffix) { - return ends_with(str, std::string(suffix)); - } - void parse_body(std::string body) { std::string delimiter = dd + boundary;