Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: forbid data: and javascript: URLs in the <base> element #41731

Merged
merged 3 commits into from
Aug 31, 2023

Conversation

annevk
Copy link
Member

@annevk annevk commented Aug 31, 2023

I created these for whatwg/html#2249.

The third test fails in Chromium and WebKit as the insertion of a new <base> element with a data: or javascript: URL does not result in an update to the document base URL. That seems like a bug to me as it makes the dynamic case different from the static case.

@annevk
Copy link
Member Author

annevk commented Aug 31, 2023

This ends up excluding a single (sub)test from Interop 2023 when merged that passed in Gecko and failed in Chromium and WebKit. Given the agreement in the issue referenced above that seems like the right thing to do.

annevk added a commit to whatwg/html that referenced this pull request Aug 31, 2023
Also correct a minor mistake in the invocation of "Is base allowed for Document?".

Tests: web-platform-tests/wpt#41731.

Fixes #2249.
@annevk annevk requested a review from domenic August 31, 2023 11:02
@annevk annevk merged commit 5dc33b8 into master Aug 31, 2023
@annevk annevk deleted the annevk/base-data-javascript branch August 31, 2023 14:20
annevk added a commit to whatwg/html that referenced this pull request Aug 31, 2023
Also correct a minor mistake in the invocation of "Is base allowed for Document?".

Tests: web-platform-tests/wpt#41731.

Fixes #2249.
webkit-commit-queue pushed a commit to annevk/WebKit that referenced this pull request Aug 31, 2023
https://bugs.webkit.org/show_bug.cgi?id=260959
rdar://114756660

Reviewed by Chris Dumez.

Document::processBaseElement did not call Document::updateBaseURL when
there was something wrong with the new base URL. However, that meant
that a newly inserted "blocked" <base> would not impact the document
base URL and instead whatever was the prior document base URL would
continue to be used.

This goes against the HTML standard which requires the first <base>
element to be used at all times and if that is "blocked" the fallback
base URL would have to be used (typically the document's URL).

Tests are upstreamed via
web-platform-tests/wpt#41731. Chromium matches
our failure, but given that it's an edge case I don't foresee any
issues.

While we're in the general area, stop invoking
Document::processBaseElement for <base> elements not connected to a
document as that results in a no-op tree traversal.

* LayoutTests/fetch/fetch-url-serialization-expected.txt:
* LayoutTests/fetch/fetch-urls.json:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base-data-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base-data.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base-javascript-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/base-javascript.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-base-element/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/url/a-element-origin-xhtml-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/url/a-element-xhtml_exclude=(file_javascript_mailto)-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/url/a-element_exclude=(file_javascript_mailto)-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/url/resources/a-element-origin.js:
(runURLTests):
* LayoutTests/imported/w3c/web-platform-tests/url/resources/a-element.js:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::processBaseElement):
* Source/WebCore/html/HTMLBaseElement.cpp:
(WebCore::HTMLBaseElement::attributeChanged):

Canonical link: https://commits.webkit.org/267498@main
@@ -0,0 +1,32 @@
<!-- Please update base-javascript.html together with this -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does having a comment instead of doctype on the first line put this into quirks mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't. In IE6 it did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants