Skip to content

Commit

Permalink
Navigation: always resolve URLs with UTF-8
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=276809

Reviewed by NOBODY (OOPS!).

Implement the spec change from whatwg/html#9756.

* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-relative-url-utf8.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-relative-url-utf8_encoding=utf8-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-relative-url-utf8_encoding=windows-1252-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/navigation-api/navigation-methods/navigate-relative-url-utf8_encoding=x-cp1251-expected.txt: Added.
* Source/WebCore/page/Navigation.cpp:
(WebCore::Navigation::navigate):
  • Loading branch information
rwlbuis committed Aug 28, 2024
1 parent ceb2721 commit 6a949d3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<meta charset={{GET[encoding]}}> <!-- ends up as <meta charset> by default which is windows-1252 -->
<meta name=variant content="?encoding=windows-1252">
<meta name=variant content="?encoding=x-cp1251">
<meta name=variant content="?encoding=utf8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe id="i" src="/common/blank.html"></iframe>
<!-- Test for https://github.com/whatwg/html/pull/9756 -->

<script>
async_test(t => {
window.onload = t.step_func(() => {
i.contentWindow.navigation.navigate("?\u00FF");

i.onload = t.step_func_done(() => {
const iframeURL = new URL(i.contentWindow.navigation.currentEntry.url);
assert_equals(iframeURL.pathname, "/common/blank.html", "pathname");
assert_equals(iframeURL.search, "?%C3%BF", "search");
});
});
}, "navigate() should resolve URLs assuming UTF-8, ignoring the document's encoding");
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


PASS navigate() should resolve URLs assuming UTF-8, ignoring the document's encoding

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


PASS navigate() should resolve URLs assuming UTF-8, ignoring the document's encoding

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


PASS navigate() should resolve URLs assuming UTF-8, ignoring the document's encoding

2 changes: 1 addition & 1 deletion Source/WebCore/page/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Navigation::Result Navigation::reload(ReloadOptions&& options, Ref<DeferredPromi
// https://html.spec.whatwg.org/multipage/nav-history-apis.html#dom-navigation-navigate
Navigation::Result Navigation::navigate(const String& url, NavigateOptions&& options, Ref<DeferredPromise>&& committed, Ref<DeferredPromise>&& finished)
{
auto newURL = window()->document()->completeURL(url);
auto newURL = window()->document()->completeURL(url, ScriptExecutionContext::ForceUTF8::Yes);
const URL& currentURL = scriptExecutionContext()->url();

if (!newURL.isValid())
Expand Down

0 comments on commit 6a949d3

Please sign in to comment.