From cc2863ed5aee9b6eb67411f50e8b92231e60ff74 Mon Sep 17 00:00:00 2001 From: Roker Date: Wed, 3 Apr 2019 14:20:25 +0200 Subject: [PATCH] RFC 2231 unwrapping is necessary for all headers... --- src/mime_headers.cc | 11 ++++++----- src/mime_headers.hh | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mime_headers.cc b/src/mime_headers.cc index 759664b..722e62e 100644 --- a/src/mime_headers.cc +++ b/src/mime_headers.cc @@ -126,14 +126,14 @@ std::string convert(std::string& charset, const std::string& input) return to_utf8(charset, input); } - -void ContentDisposition::unwrap() +// unwrap multiline header params according to RFC 2231 +void unwrap(std::vector& params) { std::vector new_params; std::string ml_name, ml_value; // multiline parameters std::string charset = "UTF-8"; int old_count = -1; - for(auto& p : dparams) + for(auto& p : params) { Rfc2231ParamName pn; std::string::const_iterator begin = p.name.cbegin(); @@ -175,7 +175,7 @@ void ContentDisposition::unwrap() } } - dparams.swap(new_params); + params.swap(new_params); } @@ -258,6 +258,7 @@ ContentType::ContentType(sv header_line) LOG << "Cannot parse \"" + std::string{cts} + "\" as ContentType.\n"; } LOG << "<<< CT raw: " << *this << ">>>\n"; + unwrap(tparams); this->sanitize(); LOG << "<<< CT san: " << *this << ">>>\n"; @@ -273,7 +274,7 @@ ContentDisposition::ContentDisposition(sv header_line) LOG << "Cannot parse \"" + std::string{cds} + "\" as ContentDisposition.\n"; } LOG << "<<< CD raw: " << *this << ">>>\n"; - this->unwrap(); + unwrap(dparams); LOG << "<<< CD uw: " << *this << ">>>\n"; } diff --git a/src/mime_headers.hh b/src/mime_headers.hh index b7b6071..04944f1 100644 --- a/src/mime_headers.hh +++ b/src/mime_headers.hh @@ -28,7 +28,6 @@ namespace pEpMIME content_disposition_type dispo_type; std::vector dparams; - void unwrap(); // reverses the wrapping of overlong (andtherefore split) parameter values. }; struct MimeHeaders : public ContentType, public ContentDisposition