Provide new, unsaved revision to PST to fix magic words.
[lhc/web/wiklou.git] / includes / parser / Sanitizer.php
index 21498f8..d885e24 100644 (file)
@@ -24,6 +24,8 @@
  * @ingroup Parser
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * HTML sanitizer for MediaWiki
  * @ingroup Parser
@@ -463,12 +465,12 @@ class Sanitizer {
         * Cleans up HTML, removes dangerous tags and attributes, and
         * removes HTML comments
         * @param string $text
-        * @param callable $processCallback Callback to do any variable or parameter
+        * @param callable|null $processCallback Callback to do any variable or parameter
         *   replacements in HTML attribute values
         * @param array|bool $args Arguments for the processing callback
         * @param array $extratags For any extra tags to include
         * @param array $removetags For any tags (default or extra) to exclude
-        * @param callable $warnCallback (Deprecated) Callback allowing the
+        * @param callable|null $warnCallback (Deprecated) Callback allowing the
         *   addition of a tracking category when bad input is encountered.
         *   DO NOT ADD NEW PARAMETERS AFTER $warnCallback, since it will be
         *   removed shortly.
@@ -1155,9 +1157,10 @@ class Sanitizer {
                $fixtags = [
                        # French spaces, last one Guillemet-left
                        # only if there is something before the space
-                       '/(.) (?=[?:;!%»])/u' => "\\1$space",
+                       # and a non-word character after the punctuation.
+                       '/(\S) (?=[?:;!%»›](?!\w))/u' => "\\1$space",
                        # French spaces, Guillemet-right
-                       '/(«) /u' => "\\1$space",
+                       '/([«‹]) /u' => "\\1$space",
                ];
                return preg_replace( array_keys( $fixtags ), array_values( $fixtags ), $text );
        }
@@ -1656,7 +1659,6 @@ class Sanitizer {
         * @return string Still normalized, without entities
         */
        public static function decodeCharReferencesAndNormalize( $text ) {
-               global $wgContLang;
                $text = preg_replace_callback(
                        self::CHAR_REFS_REGEX,
                        [ self::class, 'decodeCharReferencesCallback' ],
@@ -1666,7 +1668,7 @@ class Sanitizer {
                );
 
                if ( $count ) {
-                       return $wgContLang->normalize( $text );
+                       return MediaWikiServices::getInstance()->getContentLanguage()->normalize( $text );
                } else {
                        return $text;
                }