@@ -2549,7 +2549,7 @@ inline bool is_obs_text(char c) { return 128 <= static_cast<unsigned char>(c); }
25492549inline bool is_field_vchar (char c) { return is_vchar (c) || is_obs_text (c); }
25502550
25512551inline bool is_field_content (const std::string &s) {
2552- if (s.empty ()) { return false ; }
2552+ if (s.empty ()) { return true ; }
25532553
25542554 if (s.size () == 1 ) {
25552555 return is_field_vchar (s[0 ]);
@@ -4214,22 +4214,21 @@ inline bool parse_header(const char *beg, const char *end, T fn) {
42144214 if (!key_len) { return false ; }
42154215
42164216 auto key = std::string (beg, key_end);
4217- auto val = case_ignore::equal (key, " Location" )
4218- ? std::string (p, end)
4219- : decode_url (std::string (p, end), false );
4220-
4221- // NOTE: From RFC 9110:
4222- // Field values containing CR, LF, or NUL characters are
4223- // invalid and dangerous, due to the varying ways that
4224- // implementations might parse and interpret those
4225- // characters; a recipient of CR, LF, or NUL within a field
4226- // value MUST either reject the message or replace each of
4227- // those characters with SP before further processing or
4228- // forwarding of that message.
4229- static const std::string CR_LF_NUL (" \r\n\0 " , 3 );
4230- if (val.find_first_of (CR_LF_NUL) != std::string::npos) { return false ; }
4231-
4232- fn (key, val);
4217+ // auto val = (case_ignore::equal(key, "Location") ||
4218+ // case_ignore::equal(key, "Referer"))
4219+ // ? std::string(p, end)
4220+ // : decode_url(std::string(p, end), false);
4221+ auto val = std::string (p, end);
4222+
4223+ if (!detail::fields::is_field_value (val)) { return false ; }
4224+
4225+ if (case_ignore::equal (key, " Location" ) ||
4226+ case_ignore::equal (key, " Referer" )) {
4227+ fn (key, val);
4228+ } else {
4229+ fn (key, decode_url (val, false ));
4230+ }
4231+
42334232 return true ;
42344233 }
42354234
@@ -4265,7 +4264,7 @@ inline bool read_headers(Stream &strm, Headers &headers) {
42654264 auto end = line_reader.ptr () + line_reader.size () - line_terminator_len;
42664265
42674266 if (!parse_header (line_reader.ptr (), end,
4268- [&](const std::string &key, std::string &val) {
4267+ [&](const std::string &key, const std::string &val) {
42694268 headers.emplace (key, val);
42704269 })) {
42714270 return false ;
0 commit comments