Bug 232856

Summary: format detection applies to DOMParser and interferes with transformations of documents on iOS
Product: WebKit Reporter: Derk-Jan Hartman <hartman.wiki>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, ap, bdakin, bfulgham, cdumez, rniwa, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: iPhone / iPad   
OS: iOS 15   
Attachments:
Description Flags
testcase none

Description Derk-Jan Hartman 2021-11-08 16:07:17 PST
https://phabricator.wikimedia.org/T116525

We were trying to figure out why the WYSIWYG/HTML editor for Wikipedia kept adding tel: links in places where we had number/year ranges (like for instance 788-7705), and this was pinpointed to iOS Safari, which supports format-detection  https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW5.

After disabling this feature with the meta tag in our main document, the problem still occurred. Further investigation made us discover that not only is format-detection applied to the current/primary document, it is applied to ALL documents including ones generated by DOMParser.parseFromString() which our WYSIWYG/HTML editor relies on.

When as a developer you parse the DOM, do transformations etc, you should be able to somewhat accurately predict what DOM is being returned and these links being autogenerated are very unexpected honestly, they are not part of the document that was specified. I know we can adapt all documents we feed the parser, but I highly question these iOS features being applied to more than just the primary document and maybe iframes (and lets be honest they are annoying even there).

There also is no way to IDENTIFY these auto generated links from normal links (adding an attribute to identify this as custom iOS generate node seems like an easy/quick win). Alternatively, DOMParser could inherit format-detection settings from the main document, or there could be some sort of flag to toggle this behavior in DOMParser without us having to rewrite the entire html blobstring .....
Comment 1 Derk-Jan Hartman 2021-11-11 05:45:43 PST
Created attachment 443941 [details]
testcase
Comment 2 Derk-Jan Hartman 2021-11-11 05:53:33 PST
Added test case, showing the different behaviour on iOS (red) and macOS (green)
Comment 3 Radar WebKit Bug Importer 2021-11-15 16:08:54 PST
<rdar://problem/85433241>
Comment 4 Ahmad Saleem 2022-08-10 04:33:15 PDT
I am able to reproduce this bug in iPhone 13 Pro Max using iOS 15.6 and it shows "Red" compared to "Green" on Safari 15.6 on macOS 12.5. Just wanted to share updated results. Thanks!