#167 closed defect (worksforme)
XHTML Serializer Produces invalid XHTML
Reported by: | Armin Ronacher | Owned by: | cmlenz |
---|---|---|---|
Priority: | blocker | Milestone: | |
Component: | Serialization | Version: | 0.4.4 |
Keywords: | Cc: |
Description
The following piece of template code is serialized into wrong XHTML:
function foo() { if (foo < bar) document.write("hehe>blub"); }
The best approach would be to emit comptibility comments for style/script blocks around <CDATA sections.
Change History (5)
comment:1 Changed 17 years ago by Armin Ronacher
comment:2 Changed 17 years ago by cmlenz
This should work correctly, see #24. Can you provide a test case in code so that I can try to reproduce the problem you're seeing?
(Note also that escaping inside script blocks is in fact perfectly valid XHTML, it just isn't correct HTML. But because you're likely sending your carefully crafted XHTML using an HTML MIME type, the browser will not actually treat it as XHTML, so stuff break)
comment:3 follow-up: ↓ 4 Changed 17 years ago by Armin Ronacher
It is valid XHTML, I know. So is self closing script tags. But browsers with text/html ignore that completely.
Looking at the source code it seems like there is code from #24 in the source, however I don't get any CDATA comments/sections.
comment:4 in reply to: ↑ 3 Changed 17 years ago by cmlenz
Replying to Armin Ronacher:
Looking at the source code it seems like there is code from #24 in the source, however I don't get any CDATA comments/sections.
You have to add the CDATA sections in your template. Genshi doesn't add any of that automatically. If you do add them, however, your output will work correctly when serialized to HTML or XHTML, as CDATA markers are simply stripped by the HTMLSerializer.
XML comments in script blocks are unnecessary these days, and “evil”.
comment:5 Changed 17 years ago by cmlenz
- Milestone 0.5 deleted
- Resolution set to worksforme
- Status changed from new to closed
Closing as per previous comments.
Eh, of course inside a script tag.