Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Class for managing small XML files
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -22,18 +22,22 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* Class for managing small XML files
|
||||
*/
|
||||
class _SimpleXML extends \SimpleXMLElement
|
||||
{
|
||||
{
|
||||
/**
|
||||
* Create New XML Document
|
||||
*
|
||||
* @param string $rootElement Name of Root Element
|
||||
* @param string|NULL $xmlns Namespace
|
||||
* @return \IPS\Xml\SimpleXML
|
||||
* @note We are disabling the entity loader after opening the content to prevent XXE
|
||||
*/
|
||||
public static function create( $rootElement, $xmlns=NULL )
|
||||
{
|
||||
$entityLoaderValue = libxml_disable_entity_loader( false );
|
||||
|
||||
$string = $xmlns ? "<?xml version='1.0' encoding='UTF-8'?><{$rootElement} xmlns='{$xmlns}'></{$rootElement}>" : "<?xml version='1.0' encoding='UTF-8'?><{$rootElement}></{$rootElement}>";
|
||||
$class = @simplexml_load_string( $string, get_called_class() );
|
||||
libxml_disable_entity_loader( $entityLoaderValue );
|
||||
return $class->subtype();
|
||||
}
|
||||
|
||||
@@ -43,14 +47,18 @@ class _SimpleXML extends \SimpleXMLElement
|
||||
* @param string $filename Filename of XML file
|
||||
* @return \IPS\Xml\SimpleXML
|
||||
* @throws \InvalidArgumentException
|
||||
* @note We are disabling the entity loader after opening the content to prevent XXE
|
||||
*/
|
||||
public static function loadFile( $filename )
|
||||
{
|
||||
$entityLoaderValue = libxml_disable_entity_loader( false );
|
||||
|
||||
$class = @simplexml_load_file( $filename, get_called_class() );
|
||||
if ( $class === FALSE )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
libxml_disable_entity_loader( $entityLoaderValue );
|
||||
return $class->subtype();
|
||||
}
|
||||
|
||||
@@ -60,14 +68,18 @@ class _SimpleXML extends \SimpleXMLElement
|
||||
* @param string $xml XML
|
||||
* @return \IPS\Xml\SimpleXML
|
||||
* @throws \InvalidArgumentException
|
||||
* @note We are disabling the entity loader after opening the content to prevent XXE
|
||||
*/
|
||||
public static function loadString( $xml )
|
||||
{
|
||||
$entityLoaderValue = libxml_disable_entity_loader( false );
|
||||
|
||||
$class = @simplexml_load_string( $xml, get_called_class() );
|
||||
if ( $class === FALSE )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
}
|
||||
libxml_disable_entity_loader( $entityLoaderValue );
|
||||
return $class->subtype();
|
||||
}
|
||||
|
||||
@@ -88,8 +100,16 @@ class _SimpleXML extends \SimpleXMLElement
|
||||
{
|
||||
return \IPS\Xml\Atom::loadString( $this->asXml() );
|
||||
}
|
||||
if ( mb_strtolower( $this->getName() ) === 'rdf' )
|
||||
{
|
||||
/* Verify this is an RSS 1.0 document */
|
||||
if( in_array( 'http://purl.org/rss/1.0/', $this->getNamespaces( true ) ) )
|
||||
{
|
||||
return \IPS\Xml\Rss1::loadString( $this->asXml() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user