Bug 232856 - format detection applies to DOMParser and interferes with transformations of documents on iOS
Summary: format detection applies to DOMParser and interferes with transformations of ...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 15
Hardware: iPhone / iPad iOS 15
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-11-08 16:07 PST by Derk-Jan Hartman
Modified: 2022-08-10 04:33 PDT (History)
9 users (show)

See Also:


Attachments
testcase (1.07 KB, text/html)
2021-11-11 05:45 PST, Derk-Jan Hartman
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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!