Bug 254755 - HTML parser: only adjust approved SVG and MathML attributes
Summary: HTML parser: only adjust approved SVG and MathML attributes
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Anne van Kesteren
URL:
Keywords: InRadar
Depends on:
Blocks: 254879
  Show dependency treegraph
 
Reported: 2023-03-30 10:55 PDT by Anne van Kesteren
Modified: 2023-04-03 01:25 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anne van Kesteren 2023-03-30 10:55:22 PDT
The HTML Standard is quite particular about what attributes need to be adjusted: https://html.spec.whatwg.org/#adjust-mathml-attributes.

This results in 3 x 3 failures on WPT `html/syntax/parsing/html5lib_tests11.html`.

The fault lies in `HTMLTreeBuilder.cpp`. It uses `SVGNames::getSVGAttrs` (and seems to be only caller of that) rather than keeping its own list of known attributes. This is also the case for how it handles MathML, XLink, and XML names, but for those there are no test failures.

There are two solutions:

1. Change the tree builder to keep its own lists, similar to how the HTML Standard does it. I'm not familiar enough with C++ syntax to tackle this, but surely someone else is or can give directions. Given that the tree builder appears to be the sole consumer of `getSVGAttrs` and friends this might allow for some simplifications elsewhere in the code.
2. Remove the SVG attributes that cause the problem from `svgattrs.in`: contentScriptType, contentStyleType, and externalResourcesRequired. The first two seem fine, but the last one has some other uses it seems, but perhaps it's still safe to remove? None of these are cross-browser and technically are not supposed to work in HTML.

The main problem with 2 is that we might introduce the problem again in the future so perhaps it ought to be accompanied by asserts for the various name tables that no new camelcase names are added. Thoughts appreciated.
Comment 1 Radar WebKit Bug Importer 2023-03-30 10:55:43 PDT
<rdar://problem/107428878>
Comment 2 Anne van Kesteren 2023-04-02 00:36:44 PDT
Pull request: https://github.com/WebKit/WebKit/pull/12289
Comment 3 EWS 2023-04-03 01:25:19 PDT
Committed 262502@main (83e92a3d7ab3): <https://commits.webkit.org/262502@main>

Reviewed commits have been landed. Closing PR #12289 and removing active labels.