mirror of
https://github.com/e107inc/e107.git
synced 2025-07-09 17:16:20 +02:00
Test for toRss()
This commit is contained in:
@ -2428,6 +2428,9 @@ class e_parse extends e_parser
|
|||||||
|
|
||||||
$text = $this->ampEncode($text);
|
$text = $this->ampEncode($text);
|
||||||
|
|
||||||
|
// if CDATA happens to be quoted in the text.
|
||||||
|
$text = str_replace(['<![CDATA', ']]>'], ['<![CDATA', ']]>'], $text);
|
||||||
|
|
||||||
if($tags == true && ($text))
|
if($tags == true && ($text))
|
||||||
{
|
{
|
||||||
$text = '<![CDATA[' .$text. ']]>';
|
$text = '<![CDATA[' .$text. ']]>';
|
||||||
|
@ -536,12 +536,53 @@ while($row = $sql->fetch())
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testToRss()
|
public function testToRss()
|
||||||
{
|
{
|
||||||
|
$tests = array(
|
||||||
|
'[html]<pre class="prettyprint linenums" style="unicode-bidi: embed; direction: ltr;"></p><p><core name="e_jslib_plugin"><![CDATA[Array]]></core></p><p><core name="e_jslib_theme"><![CDATA[Array]]></core></pre>[/html]',
|
||||||
|
'<div class="something">One & Two < and > " or \'</div>',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach($tests as $html)
|
||||||
|
{
|
||||||
|
|
||||||
|
$result = $this->tp->toRss($html, true);
|
||||||
|
$valid = $this->isValidXML($result);
|
||||||
|
|
||||||
|
$this->assertTrue($valid);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function isValidXML($xmlContent)
|
||||||
|
{
|
||||||
|
if (trim($xmlContent) == '')
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$xmlContent = '<?xml version="1.0" encoding="utf-8"?>'."\n".'<description>'.$xmlContent.'</description>';
|
||||||
|
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
|
||||||
|
$doc = new DOMDocument('1.0', 'utf-8');
|
||||||
|
$doc->loadXML($xmlContent);
|
||||||
|
|
||||||
|
$errors = libxml_get_errors();
|
||||||
|
|
||||||
|
if(!empty($errors))
|
||||||
|
{
|
||||||
|
var_dump($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
libxml_clear_errors();
|
||||||
|
|
||||||
|
return empty($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
public function testPreFilter()
|
public function testPreFilter()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user