From 5a6f82c47f414e5f5a71f59ac49f840015d4ad71 Mon Sep 17 00:00:00 2001 From: Brian Wolff Date: Sun, 19 Aug 2012 14:44:00 -0300 Subject: [PATCH] (bug 38249) No PCRE unicode causes installer to spew giberish If PHP's PCRE is not compiled with unicode property support, this causes the regexes used by the parser to not compile, causing the parser to output giberish. Its been reported that the default PHP package for cent os has PCRE in such a config. As a result the installer will output total giberish. The user has no idea what went wrong because there is no meaningful output. To counter that, cause Parser to throw an exception in that case. It seemed easier than figuring out how to convince the installer not to parse the environment check. For completeness sake though I fixed the PCRE environment check to adequetely check for PCRE not having unicode support. This should be backported to 1.19 since there are quite a few complaints about the issue on project:Support_desk. /me has no idea what the procedure for that is in our new git world Change-Id: Idb1658be4ee6203a55740450e335f570a616671c --- RELEASE-NOTES-1.20 | 2 ++ includes/installer/Installer.php | 11 ++++++++++- includes/parser/Parser.php | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index 3364519630..012d04d499 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -214,6 +214,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki. are now remembered between successive clicks. * (bug 26069) Page title is no longer "Error" for all error pages * (bug 39297) Show warning if thumbnail of animated image will not be animated. +* (bug 38249) Parser will throw an exception instead of outputting gibberish if + PCRE is compiled without support for unicode properties. === API changes in 1.20 === * (bug 34316) Add ability to retrieve maximum upload size from MediaWiki API. diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php index d87f294e32..2cad7d13ed 100644 --- a/includes/installer/Installer.php +++ b/includes/installer/Installer.php @@ -788,6 +788,10 @@ abstract class Installer { /** * Environment check for the PCRE module. + * + * @note If this check were to fail, the parser would + * probably throw an exception before the result + * of this check is shown to the user. * @return bool */ protected function envCheckPCRE() { @@ -797,8 +801,13 @@ abstract class Installer { } wfSuppressWarnings(); $regexd = preg_replace( '/[\x{0430}-\x{04FF}]/iu', '', '-АБВГД-' ); + // Need to check for \p support too, as PCRE can be compiled + // with utf8 support, but not unicode property support. + // check that \p{Zs} (space separators) matches + // U+3000 (Ideographic space) + $regexprop = preg_replace( '/\p{Zs}/u', '', "-\xE3\x80\x80-" ); wfRestoreWarnings(); - if ( $regexd != '--' ) { + if ( $regexd != '--' || $regexprop != '--' ) { $this->showError( 'config-pcre-no-utf8' ); return false; } diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 2d5f966728..489451a2ef 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1522,6 +1522,9 @@ class Parser { wfProfileIn( __METHOD__ ); $bits = preg_split( $this->mExtLinkBracketedRegex, $text, -1, PREG_SPLIT_DELIM_CAPTURE ); + if ( $bits === false ) { + throw new MWException( "PCRE needs to be compiled with --enable-unicode-properties in order for MediaWiki to function" ); + } $s = array_shift( $bits ); $i = 0; -- 2.20.1