Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM: Svg attributes and tag names are being lowercased #18090

Closed
xPaw opened this issue Mar 16, 2025 · 0 comments
Closed

DOM: Svg attributes and tag names are being lowercased #18090

xPaw opened this issue Mar 16, 2025 · 0 comments

Comments

@xPaw
Copy link
Contributor

xPaw commented Mar 16, 2025

Description

All attributes are being lowercased, but for svg elements they should have correct casing (e.g. viewbox should be viewBox).

\Dom\HTMLDocument::createFromString( '<html><body><svg VIEWBOX="1 2 3 4"></svg></html>' )->saveHTML()
// <html><head></head><body><svg viewbox="1 2 3 4"></svg></body></html>


\Dom\HTMLDocument::createFromString( '<html><body><svg VIEWBOX="1 2 3 4"><feSpotLight x="10" y="10" z="50" pointsAtX="100" pointsAtY="100" limitingConeAngle="
10" /></svg></html>' )->saveHTML();
// <html><head></head><body><svg viewbox="1 2 3 4"><fespotlight x="10" y="10" z="50" pointsatx="100" pointsaty="100" limitingconeangle="10"></fespotlight></svg></body></html>


\Dom\HTMLDocument::createFromString( '<html><body><svg VIEWBOX="1 2 3 4"></svg></html>' )->querySelector('svg')->attributes[0]->name;
// viewbox

Browser repro:

dom = (new DOMParser).parseFromString('<html><body><svg VIEWBOX="1 2 3 4"></svg></html>','text/html') 
dom.documentElement.outerHTML
// <html><head></head><body><svg viewBox="1 2 3 4"></svg></body></html>


dom = (new DOMParser).parseFromString('<html><head></head><body><svg viewbox="1 2 3 4"><fespotlight x="10" y="10" z="50" pointsatx="100" pointsaty="100" limitingconeangle="10"></fespotlight></svg></body></html>','text/html') 
dom.documentElement.outerHTML
// <html><head></head><body><svg viewBox="1 2 3 4"><feSpotLight x="10" y="10" z="50" pointsAtX="100" pointsAtY="100" limitingConeAngle="10"></feSpotLight></svg></body></html>

Ref: https://html.spec.whatwg.org/multipage/parsing.html#creating-and-inserting-nodes (there is a table of attributes if you scroll a bit, there's another table for tag names as well).

Lexbor does have this attribute mapping in the code, so maybe php is just skipping it somehow: https://github.com/lexbor/lexbor/blob/9283215c15c3c7a5106a1a1e3ff16ff89900a1a5/source/lexbor/html/tree_res.h#L31

PHP Version

8.4.5

Operating System

No response

nielsdos added a commit that referenced this issue Mar 17, 2025
* PHP-8.4:
  Fix GH-18090: DOM: Svg attributes and tag names are being lowercased
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants