Closed
Bug 517842
Opened 16 years ago
Closed 16 years ago
A javascript string containing </script> is misinterpreted when using XHTML 1.1 doctype
Categories
(Firefox :: General, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: jostick, Unassigned)
References
()
Details
Attachments
(2 files, 1 obsolete file)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.3a1pre) Gecko/20090920 Minefield/3.7a1pre
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.3a1pre) Gecko/20090920 Minefield/3.7a1pre
When a HTML page with XHTML 1.1 doctype contains a javascript string like
'<div><script type="data">{}</script></div>', FF will treat the </script> in the string as end of the script tag. It does also happen when the javascript code is embedded as html comment. However the bug disappears if the doctype line is removed from the page.
Reproducible: Always
Steps to Reproduce:
1. create a minimal HTML document with XHTML 1.1 doctype
2. add a script tag that contains a string with </script> inside
3. open the document in FF
(example page provided in URL above)
Actual Results:
* Javascript error: 'unterminated string literal'
* FF shows '; -->
Expected Results:
* No Javascript error
* Empty page
| Reporter | ||
Comment 1•16 years ago
|
||
Comment 2•16 years ago
|
||
I think I see an error. You are meant to use <[CDATA[ ... ]]> instead of <!-- ... --> in XHTML.
By serving the document as text/html the xml parser is not used, so the html standards that describe what to do at http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.3.2.1 apply here.
Attachment #401799 -
Attachment is obsolete: true
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 4•16 years ago
|
||
@auscompgeek: Using <[CDATA[ ... ]]> doesn't change the outcome.
@Mardeg: Escaping the '</script>' as '<\/script>' does work. However when Javascript is inside a html comment or CDATA section, i expect it to be ignored by the parser. Am i wrong here?
Comment 5•16 years ago
|
||
Johannes, follow the link above.
Comment 6•16 years ago
|
||
Oh, and also, the file isn't actually being served as application/xhtml+xml so the XML parser doesn't kick in.
auscompgeek is correct that CDATA is how to comment when serving the document as application/xhtml+xml then there is no error because it's using the XML parser.
But then if you want to serve the document differently depending on the browser (as IE still doesn't reconise application/xhtml+xml) you run into the problems outlined at http://www.hixie.ch/advocacy/xhtml
I resolved this INVALID based on your attachment being text/html but I can change it to WORKSFORME based on this latest attachment if you like.
| Reporter | ||
Comment 8•16 years ago
|
||
No, that's fine. Thx a lot for your work and excuse my ignorance.
Have a nice day.
Comment 9•16 years ago
|
||
Just another note, in IE, the document still works. IE just looks at the DOCTYPE and sees that the XML parser should be used. But, Firefox only uses the XML parser if the MIME type has XML in it. So, the page can be served as text/html to IE while it can be served as application/xhtml+xml to other browsers.
You need to log in
before you can comment on or make changes to this bug.
Description
•