LibWebView: Avoid trying to break a schemeless URL into renderable parts

This commit is contained in:
Timothy Flynn 2023-12-04 08:54:40 -05:00 committed by Sam Atkins
parent 65a9eae142
commit 965bd00cf3
Notes: sideshowbarker 2024-07-16 23:44:30 +09:00
2 changed files with 9 additions and 1 deletions

View file

@ -24,6 +24,10 @@ TEST_CASE(invalid_url)
EXPECT(!WebView::break_url_into_parts(":/"sv).has_value());
EXPECT(!WebView::break_url_into_parts("://"sv).has_value());
EXPECT(!WebView::break_url_into_parts("/"sv).has_value());
EXPECT(!WebView::break_url_into_parts("//"sv).has_value());
EXPECT(!WebView::break_url_into_parts("/h"sv).has_value());
EXPECT(!WebView::break_url_into_parts("f"sv).has_value());
EXPECT(!WebView::break_url_into_parts("fi"sv).has_value());
EXPECT(!WebView::break_url_into_parts("fil"sv).has_value());

View file

@ -144,7 +144,11 @@ Optional<URLParts> break_url_into_parts(StringView url_string)
if (!url.is_valid())
return {};
auto scheme_length = url.scheme().bytes_as_string_view().length();
auto const& scheme = url.scheme();
auto scheme_length = scheme.bytes_as_string_view().length();
if (!url_string.starts_with(scheme))
return {};
if (!url_string.substring_view(scheme_length).starts_with("://"sv))
return {};