1776 Posts in 498 Topics by 533 members
Blog Module
SilverStripe Forums » Blog Module » RSS Feed: Description Field Escaping HTML Tags
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 994 Views |
-
RSS Feed: Description Field Escaping HTML Tags

13 September 2011 at 7:44am
I am unable to get any of my local SilverStripe RSS feeds to display properly in any browser because the HTML tags are being escaped.
Here is the markup from RSSFeed.ss:
<description>$Description.AbsoluteLinks.EscapeXML</description>
Why is this? I can't think of any reason I would want < and > to display as < and > in a browser. But when I just use $Description.XML I get parsing errors. So my workaround was to use $Description.FirstParagraph(html) but then I can't figure a way to use this with AbsoluteLinks -- which I need in order for images to show up in the feed. Can someone explain to me why we are escaping tags in this template? I just want the HTML from the content to display in the feed. Why wouldn't I??
Thanks in advance,
Garrett -
Re: RSS Feed: Description Field Escaping HTML Tags

15 November 2011 at 4:25am
I ended up adding a function to strip invalid XML:
/**
* Return the value of the field with relative links converted to absolute urls.
* @return string
*/
function AbsoluteLinks() {
$val = $this->StripInvalidXml($this->value);
return HTTP::absoluteURLs($val);
}/**
* Removes invalid XML
*
* @access public
* @param string $value
* @return string
*/
function StripInvalidXml($value)
{
$ret = "";
$current;
if (empty($value))
{
return $ret;
}
$length = strlen($value);
for ($i=0; $i < $length; $i++)
{
$current = ord($value{$i});
if (($current == 0x9) ||
($current == 0xA) ||
($current == 0xD) ||
(($current >= 0x20) && ($current <= 0xD7FF)) ||
(($current >= 0xE000) && ($current <= 0xFFFD)) ||
(($current >= 0x10000) && ($current <= 0x10FFFF)))
{
$ret .= chr($current);
}
else
{
$ret .= " ";
}
}
return $ret;
}//Garrett
-
Re: RSS Feed: Description Field Escaping HTML Tags

15 November 2011 at 4:26am
That is in sapphire/core/model/Text.php.
-
Re: RSS Feed: Description Field Escaping HTML Tags

12 August 2012 at 7:35am Last edited: 12 August 2012 7:36am
I am having this same problem, and just figured out a fix for it:
remove .EscapeXML in line 13 of sapphire/templates/RSSFeed.ss from :
<% if Description %><description>$Description.AbsoluteLinks.EscapeXML</description><% end_if %>
and add HTML in line 278 of sapphire/api/RSSFeed.php:
return $this->rssField($this->descriptionField, 'HTMLText');
Hopefully this helps someone else.
-
Re: RSS Feed: Description Field Escaping HTML Tags

11 September 2012 at 6:24pm
Hey thanks @phawley this helped a lot
| 994 Views | ||
|
Page:
1
|
Go to Top |


