Edgewall Software

Ticket #167 (closed defect: worksforme)

Opened 11 months ago

Last modified 10 months ago

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.

Attachments

Change History

  Changed 11 months ago by Armin Ronacher

Eh, of course inside a script tag.

  Changed 11 months 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)

follow-up: ↓ 4   Changed 11 months 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.

in reply to: ↑ 3   Changed 11 months 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”.

  Changed 10 months ago by cmlenz

  • status changed from new to closed
  • resolution set to worksforme
  • milestone 0.5 deleted

Closing as per previous comments.

Add/Change #167 (XHTML Serializer Produces invalid XHTML)

Author



Change Properties
<Author field>
Action
as closed
Next status will be 'reopened'
 
Note: See TracTickets for help on using tickets.