X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FMWTidy.php;h=e29ee88f6d8dcf058832ade4ebcb1d2bc4289fa4;hb=22cca24d7ebceda2cce4933646f862fd6ab394ec;hp=ed4db38cba015c2af134b6fef1951161124a13ff;hpb=2e5bfb55d73d93867c5a1fcb091e6beab2ef56db;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/MWTidy.php b/includes/parser/MWTidy.php index ed4db38cba..e29ee88f6d 100644 --- a/includes/parser/MWTidy.php +++ b/includes/parser/MWTidy.php @@ -40,13 +40,10 @@ class MWTidyWrapper { */ protected $mTokens; - protected $mUniqPrefix; - protected $mMarkerIndex; public function __construct() { $this->mTokens = null; - $this->mUniqPrefix = null; } /** @@ -55,8 +52,6 @@ class MWTidyWrapper { */ public function getWrapped( $text ) { $this->mTokens = new ReplacementArray; - $this->mUniqPrefix = "\x7fUNIQ" . - dechex( mt_rand( 0, 0x7fffffff ) ) . dechex( mt_rand( 0, 0x7fffffff ) ); $this->mMarkerIndex = 0; // Replace elements with placeholders @@ -86,7 +81,7 @@ class MWTidyWrapper { * @return string */ public function replaceCallback( $m ) { - $marker = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX; + $marker = Parser::MARKER_PREFIX . "-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX; $this->mMarkerIndex++; $this->mTokens->setPair( $marker, $m[0] ); return $marker; @@ -164,7 +159,8 @@ class MWTidy { * @param string $text HTML to check * @param bool $stderr Whether to read result from STDERR rather than STDOUT * @param int &$retval Exit code (-1 on internal error) - * @return string|null + * @return null|string + * @throws MWException */ private static function clean( $text, $stderr = false, &$retval = null ) { global $wgTidyInternal; @@ -194,7 +190,6 @@ class MWTidy { */ private static function externalClean( $text, $stderr = false, &$retval = null ) { global $wgTidyConf, $wgTidyBin, $wgTidyOpts; - wfProfileIn( __METHOD__ ); $cleansource = ''; $opts = ' -utf8'; @@ -246,7 +241,6 @@ class MWTidy { $cleansource = null; } - wfProfileOut( __METHOD__ ); return $cleansource; } @@ -261,7 +255,6 @@ class MWTidy { */ private static function phpClean( $text, $stderr = false, &$retval = null ) { global $wgTidyConf, $wgDebugTidy; - wfProfileIn( __METHOD__ ); if ( ( !wfIsHHVM() && !class_exists( 'tidy' ) ) || ( wfIsHHVM() && !function_exists( 'tidy_repair_string' ) ) @@ -269,7 +262,6 @@ class MWTidy { wfWarn( "Unable to load internal tidy class." ); $retval = -1; - wfProfileOut( __METHOD__ ); return null; } @@ -278,8 +270,6 @@ class MWTidy { if ( $stderr ) { $retval = $tidy->getStatus(); - - wfProfileOut( __METHOD__ ); return $tidy->errorBuffer; } @@ -298,7 +288,6 @@ class MWTidy { } } - wfProfileOut( __METHOD__ ); return $cleansource; } @@ -315,7 +304,7 @@ class MWTidy { */ private static function hhvmClean( $text, &$retval ) { global $wgTidyConf; - wfProfileIn( __METHOD__ ); + $cleansource = tidy_repair_string( $text, $wgTidyConf, 'utf8' ); if ( $cleansource === false ) { $cleansource = null; @@ -323,7 +312,7 @@ class MWTidy { } else { $retval = 0; } - wfProfileOut( __METHOD__ ); + return $cleansource; } }