Active
Project:
Atom
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
16 Sep 2009 at 16:46 UTC
Updated:
29 Jul 2010 at 15:44 UTC
Jump to comment: Most recent file
On my personal drupal-powerd site, tumbleweed.org.za, the atom module produces XML that contains HTML entities. This works in many clients, but fails validation on feedparser.org and firefox.
These entities are probably the result of the Markdown module, but Atom should always produce valid output.
Patch against HEAD attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | good-atom.xml_.gz | 29.36 KB | stefanor |
| #3 | bad-atom.xml_.gz | 29.37 KB | stefanor |
| #1 | atom-xml-entities2.patch | 9.08 KB | stefanor |
| atom-xml-entities.patch | 9.08 KB | stefanor |
Comments
Comment #1
stefanor commentedEek, typo in the function name in that patch. V2 attached.
Comment #2
deekayen commentedand why is this the chosen method instead of something like htmlentities()
Comment #3
stefanor commentedSome examples of the problems attached.
Comment #4
stefanor commenteddeekayen:
htmlentities() doesn't really solve this problem. De-entitfying the HTML would break it. Eg "<pre><</pre>" would become "<pre><</pre>" which is now ambiguous - we can't turn this into XML, as we don't know which entities should be escaped.
There is a built in table in PHP, get_html_translation_table, however it's incomplete. It doesn't have "mdash" for example.
Comment #5
dave reidAfter digging into this a little more the problem is that either $node->teaser or $node->body is run through check_markup by the node system via node_invoke('view', $node) or node_prepare($node). We're running check_markup on it again. The node_feed() only allows either the teaser or full content to be included in an RSS feed, and it's run only through check_plain(). If we can do that (only run each item through check_markup and check_plain once), it will work fine. The more I look into this code, the more it needs a major reorganization.
Comment #6
dave reidChanging title to absorb a few other duplicate issues:
#368819: Atom module and CCK fields
#542122: aton xml syntax error no data
Working on a patch.
Comment #7
dave reidUgh...they way that Drupal renders node content I'm not finding a way to get both a correctly formatted teaser and body. It's basically either one, but not both. I'm leaning towards making this more like the built-in RSS settings in which you can only select teasers or full text, but not both. This would make things a whole lot easier.
Comment #8
dave reidThis seems to be fixed now with the latest commits. It's semi-fixed in the Drupal 7 (HEAD) branch but I'm still trying to adjust for the new ways that node content are built. Tentatively marking as fixed.
Comment #9
dave reidYeah, nevermind. The problem still persists.
Comment #10
nschloe commentedThe above patch does not apply for me.
This is with Atom-6.x-1.1.
Comment #11
nschloe commentedHi,
just manually copied and pasted the changes into the
atom.module, and it appears to do what it's supposed to.As a result, the XML markup produced by the module contains a lot less invalid symbols. Nice!
The function
_atom_html_to_xml_entities()should also be applied to title, subtitle, and so forth.Also, the "@" symbol appears not to be legal XML markup; I guess that one should be replaced as well.
Cheers,
Nico
Comment #12
nschloe commentedAs for the "@" sign, I'm not so sure now. I just read that it should actually be legal XML, but the W3C feed validator tell me that
in the line
and points to the "@".
Comment #13
dman commentedA validation error on
<foo@bar.org>is an error with that "tag". @ is legal freetext, but not legal as an XML tag name - which is what it looks like. Plus the . plus the tag is unclosed.Comment #14
nschloe commentedSo the "<" and ">" characters should actually be converted as well? I guess it may get a little tricky here..
Comment #15
dman commentedWell, that input is crappy HTML, XHTML, XML or RSS whichever way you look at it. So there's really no reason for it to ever exist. Don't do that, it's bad.
It won't render on the screen, and it won't render in anyones reader, never mind that it doesn't parse.
GIGO
Comment #16
nschloe commentedOh, that's right! Thanks for the heads-up.
Apart from that, applying
_atom_html_to_xml_entities()to<title>,<subtitle>, and so on still remains worthwhile I believe.Cheers,
Nico