Index: trunk/phase3/install-utils.inc |
— | — | @@ -33,6 +33,16 @@ |
34 | 34 | "or higher. ABORTING. (http://bugs.php.net/bug.php?id=34879 for details)\n"; |
35 | 35 | die( -1 ); |
36 | 36 | } |
| 37 | + |
| 38 | + $test = new PhpXmlBugTester(); |
| 39 | + if( !$test->ok ) { |
| 40 | + echo "Your system has a combination of PHP and libxml2 versions which is buggy\n" . |
| 41 | + "and can cause hidden data corruption in MediaWiki and other web apps.\n" . |
| 42 | + "Upgrade to PHP 5.2.9 or later and libxml2 2.7.2 or later!\n" . |
| 43 | + "ABORTING (http://bugs.php.net/bug.php?id=45996 for details).\n"; |
| 44 | + die( -1 ); |
| 45 | + } |
| 46 | + |
37 | 47 | |
38 | 48 | global $wgCommandLineMode; |
39 | 49 | $wgCommandLineMode = true; |
— | — | @@ -40,6 +50,28 @@ |
41 | 51 | @set_time_limit( 0 ); |
42 | 52 | } |
43 | 53 | |
| 54 | +/** |
| 55 | + * Test for PHP+libxml2 bug which breaks XML input subtly with certain versions. |
| 56 | + * http://bugs.php.net/bug.php?id=45996 |
| 57 | + * Known fixed with PHP 5.2.9 + libxml2-2.7.3 |
| 58 | + */ |
| 59 | +class PhpXmlBugTester { |
| 60 | + var $parsedData = ''; |
| 61 | + var $ok = false; |
| 62 | + function __construct() { |
| 63 | + $charData = '<b>c</b>'; |
| 64 | + $xml = '<a>' . htmlspecialchars( $charData ) . '</a>'; |
| 65 | + |
| 66 | + $parser = xml_parser_create(); |
| 67 | + xml_set_character_data_handler( $parser, array( $this, 'chardata' ) ); |
| 68 | + $parsedOk = xml_parse($parser, $xml, true); |
| 69 | + $this->ok = $parsedOk && ($this->parsedData == $charData); |
| 70 | + } |
| 71 | + function chardata($parser, $data) { |
| 72 | + $this->parsedData .= $data; |
| 73 | + } |
| 74 | +} |
| 75 | + |
44 | 76 | function readconsole( $prompt = '' ) { |
45 | 77 | static $isatty = null; |
46 | 78 | if ( is_null( $isatty ) ) { |