Invalid String Output in XML View

Goldcap - September 9, 2008 - 15:41
Project:Views Datasource
Version:6.x-1.0-alpha2
Component:Code
Category:bug report
Priority:normal
Assigned:allisterbeharry
Status:closed
Description

XML doesn't allow for HTML Entities in output without a wrapping CDATA tag. Note that apostrophes and other unusual characters, even after using the following function:

views_xml_strip_illegal_chars($input)

The following xml validation error will occur:

XML Parsing Error: undefined entity
Location: http://andydev.drupal.poly.com/xml/nodes
Line Number 22, Column 21: Foo&pos;s Bar
--------------------^

Fix attatched to wrap all text nodes in CDATA tags via the XML Output theme.

AttachmentSize
views-view-xml.tpl_.php_.diff369 bytes

#1

mbutcher - October 7, 2008 - 16:36

Encoding the entities as numeric values instead of shorthand codes would also work and is cross-parser capable, since it doesn't depend on HTML-specific entities.

E.g. Instead of using amp in an entity, use #38. This would be a trivial change to views_xml.module. See the attached patch.

This can be used in conjunction with the patch above, or on its own (CDATA sections won't be necessary).

AttachmentSize
views_datasource-306066_01.patch 1.36 KB

#2

mbutcher - October 7, 2008 - 16:37
Status:active» needs review

Since this has two patches attached now, I figured I'd better change the status.

#3

dalin - September 22, 2009 - 02:28
Version:6.x-1.0-alpha2» 6.x-1.x-dev
Status:needs review» needs work

I like the idea but your patches need a bit of work. Please also patch for XHTML and RDFa. Please roll all patches into one file (preferably using cvs diff -upNR for better readability). Please do not comment out the code that you are replacing, just remove it.

This patch is racing against #286715: Invalid xml due to incorrectly encoded greater-than symbol but this is the better approach.

cheers

#4

allisterbeharry - October 8, 2009 - 13:31
Status:needs work» fixed

This problem is actually specific to one entity - the apostrophe ('). there was a typo in the code: I had &pos; instead of '. Fixed in alpha3: http://drupal.org/node/598242

#5

allisterbeharry - October 10, 2009 - 17:01
Version:6.x-1.x-dev» 6.x-1.0-alpha2
Assigned to:Anonymous» allisterbeharry

#6

System Message - October 24, 2009 - 17:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.