Skip to content

Commit 2a68087

Browse files
trflynn89tcl3
authored andcommitted
LibWeb: Do not assume hovered URLs are valid
Let's just not display any tooltip for invalid URLs. This matches how Firefox behaves.
1 parent 73b01a9 commit 2a68087

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Libraries/LibWeb/Page/EventHandler.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,10 @@ EventResult EventHandler::handle_mousemove(CSSPixelPoint visual_viewport_positio
874874
}
875875

876876
if (is_hovering_link) {
877-
page.set_is_hovering_link(true);
878-
page.client().page_did_hover_link(*document.encoding_parse_url(hovered_link_element->href()));
877+
if (auto link_url = document.encoding_parse_url(hovered_link_element->href()); link_url.has_value()) {
878+
page.set_is_hovering_link(true);
879+
page.client().page_did_hover_link(*link_url);
880+
}
879881
} else if (page.is_hovering_link()) {
880882
page.set_is_hovering_link(false);
881883
page.client().page_did_unhover_link();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<a href="https://xn--a.com">Invalid URL</a>
2+
<script>
3+
internals.movePointerTo(30, 20);
4+
</script>

0 commit comments

Comments
 (0)