@@ -2549,7 +2549,7 @@ inline bool is_obs_text(char c) { return 128 <= static_cast<unsigned char>(c); }
2549
2549
inline bool is_field_vchar (char c) { return is_vchar (c) || is_obs_text (c); }
2550
2550
2551
2551
inline bool is_field_content (const std::string &s) {
2552
- if (s.empty ()) { return false ; }
2552
+ if (s.empty ()) { return true ; }
2553
2553
2554
2554
if (s.size () == 1 ) {
2555
2555
return is_field_vchar (s[0 ]);
@@ -4214,22 +4214,21 @@ inline bool parse_header(const char *beg, const char *end, T fn) {
4214
4214
if (!key_len) { return false ; }
4215
4215
4216
4216
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
+
4233
4232
return true ;
4234
4233
}
4235
4234
@@ -4265,7 +4264,7 @@ inline bool read_headers(Stream &strm, Headers &headers) {
4265
4264
auto end = line_reader.ptr () + line_reader.size () - line_terminator_len;
4266
4265
4267
4266
if (!parse_header (line_reader.ptr (), end,
4268
- [&](const std::string &key, std::string &val) {
4267
+ [&](const std::string &key, const std::string &val) {
4269
4268
headers.emplace (key, val);
4270
4269
})) {
4271
4270
return false ;
0 commit comments