From 16b43ed03eb4370e1b5ac909d1102134dfc82f9c Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Tue, 4 Jul 2023 21:57:05 +1200 Subject: [PATCH] AK: Correct faulty logic for host state in basic URL parse The '[' and ']' code points were not being appended to the buffer for this case. --- AK/URLParser.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index e0bc81fd46..b017bbed63 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -681,18 +681,17 @@ URL URLParser::parse(StringView raw_input, Optional const& base_url, Option } // 4. Otherwise: - // FIXME: Implement closer to spec text. From reading it, shouldn't we be appending [ or ] to buffer as well? Step 3. below does not have an 'otherwise'. - // - // 1. If c is U+005B ([), then set insideBrackets to true. - else if (code_point == '[') { - inside_brackets = true; - } - // 2. If c is U+005D (]), then set insideBrackets to false. - else if (code_point == ']') { - inside_brackets = false; - } - // 3. Append c to buffer. else { + // 1. If c is U+005B ([), then set insideBrackets to true. + if (code_point == '[') { + inside_brackets = true; + } + // 2. If c is U+005D (]), then set insideBrackets to false. + else if (code_point == ']') { + inside_brackets = false; + } + + // 3. Append c to buffer. buffer.append_code_point(code_point); } break;