mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:17:36 +00:00
LibWeb: Do not crash for empty fragment in determine_the_indicated_part
The way this method is used in spec implies it should return `TopOfTheDocument` if fragment is missing.
This commit is contained in:
parent
4107c2985e
commit
41b065dec9
1 changed files with 4 additions and 6 deletions
|
@ -1742,16 +1742,14 @@ 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.
|
||||||
VERIFY(url().fragment().has_value());
|
auto fragment = url().fragment();
|
||||||
|
|
||||||
auto fragment = url().fragment().value();
|
|
||||||
|
|
||||||
// 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.has_value() || fragment->is_empty())
|
||||||
return Document::TopOfTheDocument {};
|
return Document::TopOfTheDocument {};
|
||||||
|
|
||||||
// 3. Let potentialIndicatedElement be the result of finding a potential indicated element given document and fragment.
|
// 3. Let potentialIndicatedElement be the result of finding a potential indicated element given document and fragment.
|
||||||
auto* potential_indicated_element = find_a_potential_indicated_element(fragment);
|
auto* potential_indicated_element = find_a_potential_indicated_element(*fragment);
|
||||||
|
|
||||||
// 4. If potentialIndicatedElement is not null, then return potentialIndicatedElement.
|
// 4. If potentialIndicatedElement is not null, then return potentialIndicatedElement.
|
||||||
if (potential_indicated_element)
|
if (potential_indicated_element)
|
||||||
|
@ -1759,7 +1757,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.
|
||||||
auto decoded_fragment = AK::URL::percent_decode(fragment);
|
auto decoded_fragment = AK::URL::percent_decode(*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(MUST(FlyString::from_deprecated_fly_string(decoded_fragment)));
|
potential_indicated_element = find_a_potential_indicated_element(MUST(FlyString::from_deprecated_fly_string(decoded_fragment)));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue