Bug 255205

Summary: InvalidCharacterError: The string contains invalid characters on the webfrontend of a FRITZ!Box router
Product: WebKit Reporter: thomas
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: annevk, ap, cdumez, mike, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Mac (Apple Silicon)   
OS: macOS 13   
See Also: https://bugs.webkit.org/show_bug.cgi?id=241419
https://bugs.webkit.org/show_bug.cgi?id=201699
Bug Depends on: 256385    
Bug Blocks:    
Attachments:
Description Flags
Error message in the web inspector none

Description thomas 2023-04-09 12:48:02 PDT
Created attachment 465822 [details]
Error message in the web inspector

When opening the network settings of the web frontend a FRITZ!Box router (running FRITZ!OS 7.50) the rendering of the page is interupted by this Error message in web inspector:

InvalidCharacterError: The string contains invalid characters

It refers to the function setAttribute in line 13:102 in the file html2.js, which is in combination with line 12:

function createAttributes(el, attributes={}) {
    for (let name in attributes) {
        if (attributes.hasOwnProperty(name)) {
            let value = attributes[name];
            name = name.toLowerCase();
            if (!checkAndSetEventHandler(el, name, value)) {
                if (value === true) {
                    value = "";
                }
                if (value === null || value === false) {
                    el.removeAttribute(name);
                } else if (value !== undefined) {
                    el.setAttribute(name, value);
                }
            }
        }
    }
}

I could reproduce this errror in Safari on iOS 16.4.1 and macOS 13.3.1 and also the Technology Preview 167. Chrome 112.0.5615.49 and Firefox 111.0.1 display the page w/o a problem or error.
Comment 1 Alexey Proskuryakov 2023-04-10 15:58:35 PDT
Thank you for the report! As you are looking at this in Web Inspector already, could you please share the name/value pair causing this failure? Otherwise, there isn't really a way for us to investigate, as we don't have this hardware.
Comment 2 Anne van Kesteren 2023-04-11 08:49:20 PDT
It does look like https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/Document.cpp#L427-L433 and https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/document.cc;l=491-520 are somewhat different, but all browsers might end up changing this as per bug 241419 (loosening up restrictions even more).
Comment 3 Chris Dumez 2023-04-11 08:55:16 PDT
(In reply to Anne van Kesteren from comment #2)
> It does look like
> https://github.com/WebKit/WebKit/blob/main/Source/WebCore/dom/Document.
> cpp#L427-L433 and
> https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/
> renderer/core/dom/document.cc;l=491-520 are somewhat different, but all
> browsers might end up changing this as per bug 241419 (loosening up
> restrictions even more).

If I remember correctly, we had aligned this function with the spec text and the WPT tests at the time.
Comment 4 Radar WebKit Bug Importer 2023-04-16 12:48:13 PDT
<rdar://problem/108110961>
Comment 5 Chris Dumez 2023-05-05 11:35:55 PDT
Possible regression from Bug 201699 where I was aligning with the spec.
Comment 6 thomas 2023-07-04 09:33:47 PDT
I just checked this bug with Safari Technology Preview Release 173 (Safari 17.0, WebKit 18616.1.20.2) and I can no longer reproduce the issue.
Comment 7 Chris Dumez 2023-07-05 08:42:02 PDT
(In reply to white.dog8802 from comment #6)
> I just checked this bug with Safari Technology Preview Release 173 (Safari
> 17.0, WebKit 18616.1.20.2) and I can no longer reproduce the issue.

Thanks for letting us know.
Comment 8 thomas 2023-08-21 21:53:08 PDT
In the most Safari version 16.6 (18615.3.12.11.2) I no longer can reproduce the error. Seems fixed.
Comment 9 Anne van Kesteren 2023-08-23 03:49:21 PDT
Are you sure it's because of a Safari change or might the FRITZ!Box router have received a software update?