Skip to content

Commit

Permalink
Add test code
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jan 9, 2024
1 parent 7860173 commit 3b54a23
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions htdocs/core/class/rssparser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ public function getItems()
return $this->_rssarray;
}


/**
* Parse rss URL
*
Expand All @@ -201,8 +200,6 @@ public function getItems()
*/
public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '')
{
global $conf;

include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';

Expand Down Expand Up @@ -276,6 +273,11 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '')
try {
$xmlparser = xml_parser_create(null);

xml_parser_set_option($xmlparser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($xmlparser, XML_OPTION_SKIP_WHITE, 1);
xml_parser_set_option($xmlparser, XML_OPTION_TARGET_ENCODING, "UTF-8");
//xml_set_external_entity_ref_handler($xmlparser, 'extEntHandler'); // Seems to have no effect even when function extEntHandler exists.

if (!is_resource($xmlparser) && !is_object($xmlparser)) {
$this->error = "ErrorFailedToCreateParser";
return -1;
Expand All @@ -288,6 +290,7 @@ public function parser($urlRSS, $maxNb = 0, $cachedelay = 60, $cachedir = '')
$status = xml_parse($xmlparser, $str, false);

xml_parser_free($xmlparser);

$rss = $this;
//var_dump($status.' '.$rss->_format);exit;
} catch (Exception $e) {
Expand Down Expand Up @@ -809,6 +812,22 @@ private function getAtomImageUrl(array $feed)
}


/*
* A method for the xml_set_external_entity_ref_handler()
*
* @param XMLParser $parser
* @param string $ent
* @param string|false $base
* @param string $sysID
* @param string[false $pubID
* @return bool
function extEntHandler($parser, $ent, $base, $sysID, $pubID) {
print 'extEntHandler ran';
return true;
}
*/


/**
* Function to convert an XML object into an array
*
Expand Down

0 comments on commit 3b54a23

Please sign in to comment.