-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Update Trusted Types enforcement for document.write/writeln #10328
Conversation
One thing to note is that the behaviour difference for default policy call is actually aligning with the shipping implementation (Chromium) |
424f608
to
8290d72
Compare
8290d72
to
2dc877c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All comments apply to both algorithms, though I've made some only on one of them. Apologies for the slight mess.
Thanks for the reviews so far hopefully it's looking like you expect now. Definitely cleaner than the first draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this looks good, thanks. Although now I wonder if we should have a shared operation as they are essentially copies? Maybe pass text to the document write steps and add an argument for a trailing LF? I guess @otherdaniel should agree to this as well at least.
Thanks! We're happy with this, too. |
@annevk am I okay to say this has webkit implementor interest? The webkit pr itself is being merged but I can do follow ups to change it. Mainly want it in to move away from the IDL attribute. |
https://bugs.webkit.org/show_bug.cgi?id=273819 Reviewed by Ryosuke Niwa. This patch switches document.write and writeln to use a union IDL type and single call to default policy. This brings it close to chromium behaviour. See whatwg/html#10328 * LayoutTests/imported/w3c/web-platform-tests/trusted-types/Document-write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/Document-write.html: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-write-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-write.html: * Source/WebCore/dom/Document+HTML.idl: * Source/WebCore/dom/Document.cpp: (WebCore::Document::write): (WebCore::Document::writeln): * Source/WebCore/dom/Document.h: Canonical link: https://commits.webkit.org/278501@main
I think the deduplication still needs to happen. As for implementer interest, it's a bit tricky. WebKit hasn't established a position as of yet in part due to the many outstanding issues with Trusted Types. This refactoring on its own seems okay, but I would not want that to be taken as WebKit being okay with it in general. |
I've refactored this to move things into the document write steps. |
b97d4a0
to
b7dbca8
Compare
This changes from using HTMLString to a TrustedHTML or DOMString union. This also changes the timing of the default policy call.
b7dbca8
to
ae1f8f1
Compare
No need for any change to MDN here as far as I can tell. Everything seems in order, so merging. |
https://bugs.webkit.org/show_bug.cgi?id=273819 Reviewed by Darin Adler. This patch switches document.write and writeln to use a union IDL type and single call to default policy. See whatwg/html#10328 * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-write-expected.txt: * Source/WebCore/dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createHTMLDocument): * Source/WebCore/dom/Document+HTML.idl: * Source/WebCore/dom/Document.cpp: (WebCore::Document::write): (WebCore::Document::writeln): * Source/WebCore/dom/Document.h: * Source/WebKitLegacy/mac/DOM/DOMHTMLDocument.mm: (-[DOMHTMLDocument write:]): (-[DOMHTMLDocument writeln:]): Canonical link: https://commits.webkit.org/279904@main
https://bugs.webkit.org/show_bug.cgi?id=273819 Reviewed by Darin Adler. This patch switches document.write and writeln to use a union IDL type and single call to default policy. See whatwg/html#10328 * LayoutTests/imported/w3c/web-platform-tests/trusted-types/block-string-assignment-to-Document-write-expected.txt: * Source/WebCore/dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createHTMLDocument): * Source/WebCore/dom/Document+HTML.idl: * Source/WebCore/dom/Document.cpp: (WebCore::Document::write): (WebCore::Document::writeln): * Source/WebCore/dom/Document.h: * Source/WebKitLegacy/mac/DOM/DOMHTMLDocument.mm: (-[DOMHTMLDocument write:]): (-[DOMHTMLDocument writeln:]): Canonical link: https://commits.webkit.org/279904@main
Update Trusted Types enforcement for document.write/writeln
This changes from using HTMLString to a TrustedHTML or DOMString union.
This also changes the timing of the default policy call.
(See WHATWG Working Mode: Changes for more details.)
/dom.html ( diff )
/dynamic-markup-insertion.html ( diff )
/infrastructure.html ( diff )