return $encValue;
}
+ /**
+ * Armor French spaces with a replacement character
+ *
+ * @since 1.32
+ * @param string $text Text to armor
+ * @param string $space Space character for the French spaces, defaults to ' '
+ * @return string Armored text
+ */
+ public static function armorFrenchSpaces( $text, $space = ' ' ) {
+ // Replace $ with \$ and \ with \\
+ $space = preg_replace( '#(?<!\\\\)(\\$|\\\\)#', '\\\\$1', $space );
+ $fixtags = [
+ # French spaces, last one Guillemet-left
+ # only if there is something before the space
+ '/(.) (?=\\?|:|;|!|%|\\302\\273)/' => "\\1$space",
+ # French spaces, Guillemet-right
+ '/(\\302\\253) /' => "\\1$space",
+ ];
+ return preg_replace( array_keys( $fixtags ), array_values( $fixtags ), $text );
+ }
+
/**
* Encode an attribute value for HTML tags, with extra armoring
* against further wiki processing.
'__' => '__',
] );
+ # Armor against French spaces detection (T5158)
+ $encValue = self::armorFrenchSpaces( $encValue, ' ' );
+
# Stupid hack
$encValue = preg_replace_callback(
'/((?i)' . wfUrlProtocols() . ')/',