aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrion Vibber <brion@users.mediawiki.org>2009-08-11 23:23:46 +0000
committerBrion Vibber <brion@users.mediawiki.org>2009-08-11 23:23:46 +0000
commitbeeef2e82245ff9ff2fcc73a7fb8c55f7eee45f5 (patch)
treedc3d22fb5262e1539c85e85dd28f3b7df2f347f9
parent60c805b761402f8ca8ad1e1c46bc4a5f0b04afdf (diff)
downloadmediawikicore-beeef2e82245ff9ff2fcc73a7fb8c55f7eee45f5.tar.gz
mediawikicore-beeef2e82245ff9ff2fcc73a7fb8c55f7eee45f5.zip
Add an install/update-time test for the PHP+libxml2 horrible XML input corruption bug. Now need to find a known-bad system to confirm the test on :D
Notes
Notes: http://mediawiki.org/wiki/Special:Code/MediaWiki/54828
-rw-r--r--install-utils.inc32
1 files changed, 32 insertions, 0 deletions
diff --git a/install-utils.inc b/install-utils.inc
index 473cdf56a7f0..d8f73ceb048c 100644
--- a/install-utils.inc
+++ b/install-utils.inc
@@ -33,6 +33,16 @@ function install_version_checks() {
"or higher. ABORTING. (http://bugs.php.net/bug.php?id=34879 for details)\n";
die( -1 );
}
+
+ $test = new PhpXmlBugTester();
+ if( !$test->ok ) {
+ echo "Your system has a combination of PHP and libxml2 versions which is buggy\n" .
+ "and can cause hidden data corruption in MediaWiki and other web apps.\n" .
+ "Upgrade to PHP 5.2.9 or later and libxml2 2.7.2 or later!\n" .
+ "ABORTING (http://bugs.php.net/bug.php?id=45996 for details).\n";
+ die( -1 );
+ }
+
global $wgCommandLineMode;
$wgCommandLineMode = true;
@@ -40,6 +50,28 @@ function install_version_checks() {
@set_time_limit( 0 );
}
+/**
+ * Test for PHP+libxml2 bug which breaks XML input subtly with certain versions.
+ * http://bugs.php.net/bug.php?id=45996
+ * Known fixed with PHP 5.2.9 + libxml2-2.7.3
+ */
+class PhpXmlBugTester {
+ var $parsedData = '';
+ var $ok = false;
+ function __construct() {
+ $charData = '<b>c</b>';
+ $xml = '<a>' . htmlspecialchars( $charData ) . '</a>';
+
+ $parser = xml_parser_create();
+ xml_set_character_data_handler( $parser, array( $this, 'chardata' ) );
+ $parsedOk = xml_parse($parser, $xml, true);
+ $this->ok = $parsedOk && ($this->parsedData == $charData);
+ }
+ function chardata($parser, $data) {
+ $this->parsedData .= $data;
+ }
+}
+
function readconsole( $prompt = '' ) {
static $isatty = null;
if ( is_null( $isatty ) ) {