LibWeb: Return the correct substring when parsing an HTTP quoted string

We were off-by-one when returning the result of parsing a quoted string
in Web::Fetch::Infrastructure::collect_an_http_quoted_string. Instead of
backtracking the lexer and consuming the backtracked string, do a simple
substring operation.
This commit is contained in:
Timothy Flynn 2024-03-26 12:13:11 -04:00 committed by Luke Wilde
parent 576c2f4f4d
commit d74059580c
Notes: sideshowbarker 2024-07-17 05:19:06 +09:00
4 changed files with 72 additions and 4 deletions

View file

@ -72,10 +72,7 @@ ErrorOr<String> collect_an_http_quoted_string(GenericLexer& lexer, HttpQuotedStr
return value.to_string();
// 7. Return the code points from positionStart to position, inclusive, within input.
auto position = lexer.tell();
auto number_of_characters_to_consume = position - position_start + 1;
lexer.retreat(number_of_characters_to_consume);
return String::from_utf8(lexer.consume(number_of_characters_to_consume));
return String::from_utf8(lexer.input().substring_view(position_start, lexer.tell() - position_start));
}
}