PDA

View Full Version : single quote in site title breaks atom feed


maarten
05-05-2008, 12:12 PM
When using a single quote in 'the site title' the atom feed gets a XML valdidation error. This because the single quote, in $pixelpost_site_title, isn't getting escaped.

in functions_feeds.php:


$atom .= "<link rel='alternate' type='text/html' href='".$cfgrow['siteurl']."' title='".$pixelpost_site_title."' />\n";
$atom .= "<link rel='self' type='application/atom+xml' href='".$cfgrow['siteurl']."index.php?x=atom' title='".$pixelpost_site_title."' />\n";


so that code makes, for example my site title " Maarten's kiekjes " invalid XML:


<link rel='alternate' type='text/html' href='http://www.localnut.org/' title='Maarten's kiekjes' />
<link rel='self' type='application/atom+xml' href='http://www.localnut.org/index.php?x=atom' title='Maarten's kiekjes' />



made a (quick & dirty) hack to make it produce valid XML :


//$atom .= "<link rel='alternate' type='text/html' href='".$cfgrow['siteurl']."' title='".$pixelpost_site_title."' />\n";
$atom .= '<link rel="alternate" type="text/html" href="'.$cfgrow['siteurl'].'" title="'.$pixelpost_site_title.'" />';
$atom .= "\n";
//$atom .= "<link rel='self' type='application/atom+xml' href='".$cfgrow['siteurl']."index.php?x=atom' title='".$pixelpost_site_title."' />\n";
$atom .= '<link rel="self" type="application/atom+xml" href="'.$cfgrow['siteurl'].'index.php?x=atom" title="'.$pixelpost_site_title.'" />';
$atom .= "\n";


which make the atom XML valid:

<link rel="alternate" type="text/html" href="http://www.localnut.org/" title="Maarten's kiekjes"/>
<link rel="self" type="application/atom+xml" href="http://www.localnut.org/index.php?x=atom" title="Maarten's kiekjes"/>




Maarten

kevincrafts
05-05-2008, 04:49 PM
Have you tried using the html entity instead?

Replace your single quote with this:

&apos;

Not sure if that is valid in the feed or not though.