In view-source output, U+003C less-than sign in SVG <script> element is flagged as an error




3 years ago
3 years ago


(Reporter: mike, Unassigned)


Firefox Tracking Flags

(Not tracked)





3 years ago
Steps to reproduce:

1. Open view-source:
2. Observe that in line 12 the U+003C less-than sign is red.
3. Hover over the red U+003C less-than sign in line 12 and observe that Firefox shows the following error message:

   Bad character “ ” after “<”. Probable cause: Unescaped “<”. Try escaping it as “&lt;”

I’m think this behavior is correct per the HTML spec and SVG specs, but am filing this bug to help have a record here.

I believe the reason behavior is correct is that per the SVG spec, that U+003C is not allowed in any SVG element—similar to the way U+003C is not allowed in most HTML elements (what the HTML spec calls “normal elements“), but instead only in the HTML “raw text elements” <script> and <style> and the HTML “escapable raw text element” <textarea> and <title>—and the HTML spec does not similarly classify the SVG script element as a “raw text element” covered by special rules in the HTML parsing algorithm

All that said, since that U+003C goes into the DOM as expected and browsers execute the content of that SVG <script> element as expected, perhaps the HTML parsing algorithm should be changed to allow U+003C in SVG <script> elements in the same way it allows U+003C in HTML <script> elements—that is, to require the same specific “raw text elements” handling for SVG <script> elements as it does for HTML <script> elements.

I’ve filed to propose that.

 - The content of SVG script elements is tokenized like they are tokenized in XML—not like the content of HTML script elements is tokenized.

 - When an SVG or MathML element is open <![CDATA[…]]> sections work the way they do in XML. You can use this to hide text content from older browsers that don’t support SVG or MathML in text/html.
Last Resolved: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.