-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1386 from sun/xml-load-strict
Limit strict error handling in XML::load() to configuration
- Loading branch information
Showing
2 changed files
with
7 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,10 +84,11 @@ public static function prepareString($string) | |
* @param string $filename | ||
* @param boolean $isHtml | ||
* @param boolean $xinclude | ||
* @param boolean $strict | ||
* @return DOMDocument | ||
* @since Method available since Release 3.3.0 | ||
*/ | ||
public static function loadFile($filename, $isHtml = false, $xinclude = false) | ||
public static function loadFile($filename, $isHtml = false, $xinclude = false, $strict = false) | ||
{ | ||
$reporting = error_reporting(0); | ||
$contents = file_get_contents($filename); | ||
|
@@ -102,7 +103,7 @@ public static function loadFile($filename, $isHtml = false, $xinclude = false) | |
); | ||
} | ||
|
||
return self::load($contents, $isHtml, $filename, $xinclude); | ||
return self::load($contents, $isHtml, $filename, $xinclude, $strict); | ||
} | ||
|
||
/** | ||
|
@@ -123,13 +124,14 @@ public static function loadFile($filename, $isHtml = false, $xinclude = false) | |
* @param boolean $isHtml | ||
* @param string $filename | ||
* @param boolean $xinclude | ||
* @param boolean $strict | ||
* @return DOMDocument | ||
* @since Method available since Release 3.3.0 | ||
* @author Mike Naberezny <[email protected]> | ||
* @author Derek DeVries <[email protected]> | ||
* @author Tobias Schlitt <[email protected]> | ||
*/ | ||
public static function load($actual, $isHtml = false, $filename = '', $xinclude = false) | ||
public static function load($actual, $isHtml = false, $filename = '', $xinclude = false, $strict = false) | ||
{ | ||
if ($actual instanceof DOMDocument) { | ||
return $actual; | ||
|
@@ -173,7 +175,7 @@ public static function load($actual, $isHtml = false, $filename = '', $xinclude | |
chdir($cwd); | ||
} | ||
|
||
if ($loaded === false || $message !== '') { | ||
if ($loaded === false || ($strict && $message !== '')) { | ||
if ($filename !== '') { | ||
throw new PHPUnit_Framework_Exception( | ||
sprintf( | ||
|