mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-06 08:10:02 +00:00
LibWeb: Avoid dereferencing an empty optional URL
Here, "null" means the empty optional. We don't need to also check if the URL is valid; the url will be null if it was originally invalid.
This commit is contained in:
parent
0bc55424c8
commit
943ec820fc
Notes:
github-actions[bot]
2024-12-11 17:34:46 +00:00
Author: https://github.com/trflynn89
Commit: 943ec820fc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2880
Reviewed-by: https://github.com/tcl3 ✅
3 changed files with 10 additions and 1 deletions
|
@ -427,7 +427,7 @@ String HTMLHyperlinkElementUtils::href() const
|
||||||
return String {};
|
return String {};
|
||||||
|
|
||||||
// 4. Otherwise, if url is null, return this element's href content attribute's value.
|
// 4. Otherwise, if url is null, return this element's href content attribute's value.
|
||||||
if (!url->is_valid())
|
if (!url.has_value())
|
||||||
return href_content_attribute.release_value();
|
return href_content_attribute.release_value();
|
||||||
|
|
||||||
// 5. Return url, serialized.
|
// 5. Return url, serialized.
|
||||||
|
|
1
Tests/LibWeb/Text/expected/HTML/href-invalid.txt
Normal file
1
Tests/LibWeb/Text/expected/HTML/href-invalid.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
href="http://foo:b/c"
|
8
Tests/LibWeb/Text/input/HTML/href-invalid.html
Normal file
8
Tests/LibWeb/Text/input/HTML/href-invalid.html
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = "http://foo:b/c";
|
||||||
|
println(`href="${a.href}"`);
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue