Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit cd4fbd0

Browse files
committed
Merge pull request zendframework#461 from Nazin/master
CDATA section for category elements in RSS feed
2 parents 7c18367 + d166b4f commit cd4fbd0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

library/Zend/Feed/Rss.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ protected function _mapFeedEntries(DOMElement $root, $array)
433433

434434
if (isset($dataentry->category)) {
435435
foreach ($dataentry->category as $category) {
436-
$node = $this->_element->createElement('category', $category['term']);
436+
$node = $this->_element->createElement('category');
437+
$node->appendChild($this->_element->createCDATASection($category['term']));
437438
if (isset($category['scheme'])) {
438439
$node->setAttribute('domain', $category['scheme']);
439440
}

tests/Zend/Feed/Writer/Renderer/Entry/RssTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,17 @@ public function testCategoriesCharDataEncoding()
367367
$this->assertEquals($expected, (array) $entry->getCategories());
368368
}
369369

370+
/**
371+
* @group GH-461
372+
*/
373+
public function testCategoryHasCDataSection()
374+
{
375+
$this->_validEntry->addCategory(array(
376+
'term' => 'This is a test category',
377+
));
378+
$renderer = new Zend_Feed_Writer_Renderer_Feed_Rss($this->_validWriter);
379+
$xmlString = $renderer->render()->saveXml();
380+
$this->assertContains('<category><![CDATA[This is a test category]]></category>', $xmlString);
381+
}
382+
370383
}

0 commit comments

Comments
 (0)