Bug 216216 - XML documents in iframes should not inherit encoding from parent frame
Summary: XML documents in iframes should not inherit encoding from parent frame
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-05 12:42 PDT by Alex Christensen
Modified: 2020-09-05 13:55 PDT (History)
5 users (show)

See Also:


Attachments
Patch (3.40 KB, patch)
2020-09-05 12:44 PDT, Alex Christensen
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-09-05 12:42:46 PDT
XML documents in iframes should not inherit encoding from parent frame
Comment 1 Alex Christensen 2020-09-05 12:44:00 PDT
Created attachment 408093 [details]
Patch
Comment 2 Darin Adler 2020-09-05 12:48:41 PDT
Comment on attachment 408093 [details]
Patch

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

> Source/WebCore/loader/DocumentWriter.cpp:61
> +    if (auto* document = frame ? frame->document() : nullptr) {
> +        if (document->isXMLDocument())
> +            return false;
> +    }

The code in this function dereferences frame without checking for null. And the only caller already dereferences the frame before calling this function. So we do not need to check for null here. We should change the argument type to a reference.

Also, the only caller calls this function twice in a row. It should use a boolean local instead.

Could write this:

    if (is<XMLDocument>(frame->document()))
        return false;

The null check is built into the is<> function. But also, the code below uses frame->document() without checking it for null either.
Comment 3 Darin Adler 2020-09-05 12:50:22 PDT
Comment on attachment 408093 [details]
Patch

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

> Source/WebCore/loader/DocumentWriter.cpp:59
> +        if (document->isXMLDocument())

Maybe this should be done the other way around, where the HTMLDocument case is the special one:

    if (!is<HTMLDocument>(frame->document()))
        return false;

Or:

    return is<HTMLDocument>(frame->document())
        && parentFrame && ...
Comment 4 Alex Christensen 2020-09-05 13:54:57 PDT
http://trac.webkit.org/r266671
Comment 5 Radar WebKit Bug Importer 2020-09-05 13:55:14 PDT
<rdar://problem/68404034>