mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 12:47:35 +00:00
AK+LibWeb: Do not percent encode/decode in URL fragment setter/getters
The web specs do not expect decoding or decoding to happen when calling these helpers. This allows us to remove the raw_fragment helper function from the URL class.
This commit is contained in:
parent
c25485700a
commit
5663a2d3b4
3 changed files with 3 additions and 11 deletions
|
@ -63,11 +63,6 @@ DeprecatedString URL::basename() const
|
||||||
}
|
}
|
||||||
|
|
||||||
DeprecatedString URL::fragment() const
|
DeprecatedString URL::fragment() const
|
||||||
{
|
|
||||||
return percent_decode(m_fragment);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeprecatedString URL::raw_fragment() const
|
|
||||||
{
|
{
|
||||||
return m_fragment;
|
return m_fragment;
|
||||||
}
|
}
|
||||||
|
@ -142,7 +137,7 @@ void URL::append_path(StringView path)
|
||||||
|
|
||||||
void URL::set_fragment(StringView fragment)
|
void URL::set_fragment(StringView fragment)
|
||||||
{
|
{
|
||||||
m_fragment = deprecated_string_percent_encode(fragment, PercentEncodeSet::Fragment);
|
m_fragment = fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
|
||||||
|
|
2
AK/URL.h
2
AK/URL.h
|
@ -83,9 +83,7 @@ public:
|
||||||
ErrorOr<String> serialized_host() const;
|
ErrorOr<String> serialized_host() const;
|
||||||
DeprecatedString basename() const;
|
DeprecatedString basename() const;
|
||||||
Optional<String> const& query() const { return m_query; }
|
Optional<String> const& query() const { return m_query; }
|
||||||
// NOTE: fragment() is percent-decoded, raw_fragment() is not.
|
|
||||||
DeprecatedString fragment() const;
|
DeprecatedString fragment() const;
|
||||||
DeprecatedString raw_fragment() const;
|
|
||||||
Optional<u16> port() const { return m_port; }
|
Optional<u16> port() const { return m_port; }
|
||||||
DeprecatedString path_segment_at_index(size_t index) const;
|
DeprecatedString path_segment_at_index(size_t index) const;
|
||||||
size_t path_segment_count() const { return m_paths.size(); }
|
size_t path_segment_count() const { return m_paths.size(); }
|
||||||
|
|
|
@ -1737,7 +1737,7 @@ Document::IndicatedPart Document::determine_the_indicated_part() const
|
||||||
// For an HTML document document, the following processing model must be followed to determine its indicated part:
|
// For an HTML document document, the following processing model must be followed to determine its indicated part:
|
||||||
|
|
||||||
// 1. Let fragment be document's URL's fragment.
|
// 1. Let fragment be document's URL's fragment.
|
||||||
auto fragment = url().raw_fragment();
|
auto fragment = url().fragment();
|
||||||
|
|
||||||
// 2. If fragment is the empty string, then return the special value top of the document.
|
// 2. If fragment is the empty string, then return the special value top of the document.
|
||||||
if (fragment.is_empty())
|
if (fragment.is_empty())
|
||||||
|
@ -1752,8 +1752,7 @@ Document::IndicatedPart Document::determine_the_indicated_part() const
|
||||||
|
|
||||||
// 5. Let fragmentBytes be the result of percent-decoding fragment.
|
// 5. Let fragmentBytes be the result of percent-decoding fragment.
|
||||||
// 6. Let decodedFragment be the result of running UTF-8 decode without BOM on fragmentBytes.
|
// 6. Let decodedFragment be the result of running UTF-8 decode without BOM on fragmentBytes.
|
||||||
// NOTE: 5 and 6 are done as a single step in `AK::URL::fragment()`.
|
auto decoded_fragment = AK::URL::percent_decode(fragment);
|
||||||
auto decoded_fragment = url().fragment();
|
|
||||||
|
|
||||||
// 7. Set potentialIndicatedElement to the result of finding a potential indicated element given document and decodedFragment.
|
// 7. Set potentialIndicatedElement to the result of finding a potential indicated element given document and decodedFragment.
|
||||||
potential_indicated_element = find_a_potential_indicated_element(decoded_fragment);
|
potential_indicated_element = find_a_potential_indicated_element(decoded_fragment);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue