Bug 209174 - Add routines to check about:blank and about:srcdoc URLs
Summary: Add routines to check about:blank and about:srcdoc URLs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Page Loading (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-03-17 02:57 PDT by youenn fablet
Modified: 2020-03-23 02:45 PDT (History)
13 users (show)

See Also:


Attachments
Patch (8.84 KB, patch)
2020-03-17 02:59 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (8.84 KB, patch)
2020-03-19 02:38 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (9.10 KB, patch)
2020-03-19 06:09 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (12.80 KB, patch)
2020-03-19 07:18 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (16.55 KB, patch)
2020-03-20 04:15 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2020-03-17 02:57:07 PDT
Add routines to check about:blank and about:srcdoc URLs
Comment 1 youenn fablet 2020-03-17 02:59:19 PDT
Created attachment 393738 [details]
Patch
Comment 2 youenn fablet 2020-03-19 02:38:54 PDT
Created attachment 393957 [details]
Patch
Comment 3 youenn fablet 2020-03-19 06:06:16 PDT
Two tests are failing:

imported/w3c/web-platform-tests/html/dom/usvstring-reflection.https.html gets some more PASS. I believe the issue was that we were comparing "about:blank" with "about:blank#xxx" and we are now no longer checking the hash. Seems like an improvement.

http/tests/dom/window-open-about-uppercase-blank-and-access-document.html is now failing and is specifically trying to do window.open("about:BLANK").
Both Firefox and Chrome pass the test but with different behaviours. They treat about:BLANK as somehow different from about:blank though. For instance Chrome will end-up loading "about:blank#blocked". Probably the navigation starts with "about:blank", tries to go to "about:BLANK" which is blocked.

I guess we could make a DOMWindow::open specific fix here, or preserve for now SecurityPolicy::shouldInheritSecurityOriginFromOwner behavior.
Comment 4 youenn fablet 2020-03-19 06:09:15 PDT
Created attachment 393971 [details]
Patch
Comment 5 youenn fablet 2020-03-19 07:18:42 PDT
Created attachment 393976 [details]
Patch
Comment 6 youenn fablet 2020-03-20 04:15:30 PDT
Created attachment 394076 [details]
Patch
Comment 7 Alex Christensen 2020-03-20 09:46:41 PDT
Comment on attachment 394076 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394076&action=review

> Source/WTF/wtf/URL.h:262
>  WTF_EXPORT_PRIVATE const URL& blankURL();

I think we should rename this.
Comment 8 youenn fablet 2020-03-20 09:52:02 PDT
Comment on attachment 394076 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394076&action=review

>> Source/WTF/wtf/URL.h:262
>>  WTF_EXPORT_PRIVATE const URL& blankURL();
> 
> I think we should rename this.

Agreed, it should be aboutBlankURL probably.
Comment 9 youenn fablet 2020-03-20 09:52:40 PDT
https://bugs.webkit.org/show_bug.cgi?id=209344
Comment 10 EWS 2020-03-20 10:40:50 PDT
Committed r258769: <https://trac.webkit.org/changeset/258769>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 394076 [details].
Comment 11 Radar WebKit Bug Importer 2020-03-20 10:41:18 PDT
<rdar://problem/60692601>
Comment 12 Darin Adler 2020-03-20 13:01:02 PDT
Comment on attachment 394076 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394076&action=review

> Source/WTF/wtf/URL.cpp:1026
> +    return protocolIsAbout() && path() == "blank";

Case sensitive. On purpose? I see FIXME that implies it is. But also, I would like to see test coverage.

> Source/WTF/wtf/URL.cpp:1031
> +    return protocolIsAbout() && path() == "srcdoc";

Ditto.
Comment 13 Darin Adler 2020-03-20 13:05:15 PDT
Comment on attachment 394076 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=394076&action=review

> Source/WTF/wtf/URL.cpp:878
> +    static NeverDestroyed<URL> staticAboutSrcDocURL(URL(), "about:srcdoc");

I wonder if we should include const for things like this.

    static const NeverDestroyed<URL> ...

Not sure if this has enough value to be worth including the extra keyword.

> Source/WebCore/html/HTMLFrameElementBase.cpp:156
> +        return WTF::aboutSrcDocURL();

Should not need a WTF prefix. Normally for WTF we are putting "using" in the header itself. I would like to stay consistent one way or the other.

> Source/WebCore/loader/FrameLoader.cpp:3714
> -    if (!equalLettersIgnoringASCIICase(url.string(), "about:srcdoc"))
> +    if (!url.isAboutSrcDoc())

Here we changed behavior. Do we have test coverage?

> Source/WebCore/page/SecurityPolicy.cpp:170
> +    // FIXME: We also allow some URLs like "about:BLANK". We should probably block navigation to these URLs, see rdar://problem/57966056.
> +    return url.isEmpty() || url.isAboutBlank() || url.isAboutSrcDoc() || equalIgnoringASCIICase(url.string(), WTF::blankURL());

Here we preserved this old behavior, and the FIXME suggests changing bahvior. Do we have test coverage either way?

> Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:82
> -        && !equalIgnoringASCIICase(openerUrl.string(), WTF::blankURL())) {
> +        && !openerUrl.isAboutBlank()) {

Here we changed behavior. Do we have test coverage?
Comment 14 youenn fablet 2020-03-23 02:45:28 PDT
> > Source/WebCore/html/HTMLFrameElementBase.cpp:156
> > +        return WTF::aboutSrcDocURL();
> 
> Should not need a WTF prefix. Normally for WTF we are putting "using" in the
> header itself. I would like to stay consistent one way or the other.

Will fix it.

> > Source/WebCore/loader/FrameLoader.cpp:3714
> > -    if (!equalLettersIgnoringASCIICase(url.string(), "about:srcdoc"))
> > +    if (!url.isAboutSrcDoc())
> 
> Here we changed behavior. Do we have test coverage?

I do not think we are changing behavior since this is an early return.
We are early returning more often but, in the cases where we were not, ownerElement->hasAttributeWithoutSynchronization(srcdocAttr) would catch the other cases.

> > Source/WebCore/page/SecurityPolicy.cpp:170
> > +    // FIXME: We also allow some URLs like "about:BLANK". We should probably block navigation to these URLs, see rdar://problem/57966056.
> > +    return url.isEmpty() || url.isAboutBlank() || url.isAboutSrcDoc() || equalIgnoringASCIICase(url.string(), WTF::blankURL());
> 
> Here we preserved this old behavior, and the FIXME suggests changing
> bahvior. Do we have test coverage either way?

We have test coverage here: http/tests/dom/window-open-about-uppercase-blank-and-access-document.html.

> > Source/WebKit/WebProcess/WebCoreSupport/WebResourceLoadObserver.cpp:82
> > -        && !equalIgnoringASCIICase(openerUrl.string(), WTF::blankURL())) {
> > +        && !openerUrl.isAboutBlank()) {
> 
> Here we changed behavior. Do we have test coverage?

Right.
John, do you know how we can exercise that code path?