1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 03:48:13 +00:00

LibWeb: Complete the URL in href_setter() before trying to load it

Also note that setting an invalid URL here should raise a JS exception
(and not navigate away).
Fixes #4301.
This commit is contained in:
AnotherTest 2020-12-02 12:09:24 +03:30 committed by Andreas Kling
parent 3565d3c60c
commit d1a5b4d906
3 changed files with 8 additions and 3 deletions

View file

@ -70,7 +70,12 @@ JS_DEFINE_NATIVE_SETTER(LocationObject::href_setter)
auto new_href = value.to_string(global_object);
if (vm.exception())
return;
window.impl().did_set_location_href({}, new_href);
auto href_url = window.impl().document().complete_url(new_href);
if (!href_url.is_valid()) {
vm.throw_exception<JS::URIError>(global_object, String::formatted("Invalid URL '{}'", new_href));
return;
}
window.impl().did_set_location_href({}, href_url);
}
JS_DEFINE_NATIVE_GETTER(LocationObject::pathname_getter)