From db5ad0c2b0229084f762cd35392cba4f6c3f56bd Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 6 Aug 2023 16:43:50 +1200 Subject: [PATCH] AK: Remove ApplyPercentDecoding from URL Nowhere was setting this flag from the default. --- AK/URL.cpp | 28 ++++++++++++++-------------- AK/URL.h | 14 +++++++------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/AK/URL.cpp b/AK/URL.cpp index 6ba190facf..64f89e7479 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -36,40 +36,40 @@ URL URL::complete_url(StringView relative_url) const return URLParser::basic_parse(relative_url, *this); } -DeprecatedString URL::username(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::username() const { - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_username) : m_username; + return percent_decode(m_username); } -DeprecatedString URL::password(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::password() const { - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_password) : m_password; + return percent_decode(m_password); } -DeprecatedString URL::path_segment_at_index(size_t index, ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::path_segment_at_index(size_t index) const { VERIFY(index < path_segment_count()); - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_paths[index]) : m_paths[index]; + return percent_decode(m_paths[index]); } -DeprecatedString URL::basename(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::basename() const { if (!m_valid) return {}; if (m_paths.is_empty()) return {}; auto& last_segment = m_paths.last(); - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(last_segment) : last_segment; + return percent_decode(last_segment); } -DeprecatedString URL::query(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::query() const { - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_query) : m_query; + return m_query; } -DeprecatedString URL::fragment(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::fragment() const { - return apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(m_fragment) : m_fragment; + return percent_decode(m_fragment); } // NOTE: This only exists for compatibility with the existing URL tests which check for both .is_null() and .is_empty(). @@ -276,14 +276,14 @@ bool URL::is_special_scheme(StringView scheme) return scheme.is_one_of("ftp", "file", "http", "https", "ws", "wss"); } -DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const +DeprecatedString URL::serialize_path() const { if (cannot_be_a_base_url()) return m_paths[0]; StringBuilder builder; for (auto& path : m_paths) { builder.append('/'); - builder.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(path) : path); + builder.append(percent_decode(path)); } return builder.to_deprecated_string(); } diff --git a/AK/URL.h b/AK/URL.h index b2e0c4ce5f..de47383990 100644 --- a/AK/URL.h +++ b/AK/URL.h @@ -77,15 +77,15 @@ public: No }; DeprecatedString const& scheme() const { return m_scheme; } - DeprecatedString username(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; - DeprecatedString password(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; + DeprecatedString username() const; + DeprecatedString password() const; Host const& host() const { return m_host; } ErrorOr serialized_host() const; - DeprecatedString basename(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; - DeprecatedString query(ApplyPercentDecoding = ApplyPercentDecoding::No) const; - DeprecatedString fragment(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; + DeprecatedString basename() const; + DeprecatedString query() const; + DeprecatedString fragment() const; Optional port() const { return m_port; } - DeprecatedString path_segment_at_index(size_t index, ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; + DeprecatedString path_segment_at_index(size_t index) const; size_t path_segment_count() const { return m_paths.size(); } u16 port_or_default() const { return m_port.value_or(default_port_for_scheme(m_scheme)); } @@ -111,7 +111,7 @@ public: m_paths.append(""); } - DeprecatedString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const; + DeprecatedString serialize_path() const; DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const; DeprecatedString serialize_for_display() const; DeprecatedString to_deprecated_string() const { return serialize(); }