X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;ds=sidebyside;f=includes%2Fparser%2FPreprocessor_DOM.php;h=950d66d7b7bdbec66a65aff7aea11bf67be1a552;hb=23fd64afde218cdd54f3a21980c029f31b507b65;hp=5da7cd7441c62e4d74b0f9a47cb1deaebb38deac;hpb=120e275384a65e9e255b1aebdf5c9d4bddd15d8e;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Preprocessor_DOM.php b/includes/parser/Preprocessor_DOM.php index 5da7cd7441..950d66d7b7 100644 --- a/includes/parser/Preprocessor_DOM.php +++ b/includes/parser/Preprocessor_DOM.php @@ -193,6 +193,8 @@ class Preprocessor_DOM extends Preprocessor { * @return string */ public function preprocessToXml( $text, $flags = 0 ) { + global $wgDisableLangConversion; + $forInclusion = $flags & Parser::PTD_FOR_INCLUSION; $xmlishElements = $this->parser->getStripList(); @@ -220,6 +222,10 @@ class Preprocessor_DOM extends Preprocessor { $stack = new PPDStack; $searchBase = "[{<\n"; # } + if ( !$wgDisableLangConversion ) { + $searchBase .= '-'; + } + // For fast reverse searches $revText = strrev( $text ); $lengthText = strlen( $text ); @@ -298,7 +304,10 @@ class Preprocessor_DOM extends Preprocessor { break; } } else { - $curChar = $text[$i]; + $curChar = $curTwoChar = $text[$i]; + if ( ( $i + 1 ) < $lengthText ) { + $curTwoChar .= $text[$i + 1]; + } if ( $curChar == '|' ) { $found = 'pipe'; } elseif ( $curChar == '=' ) { @@ -311,11 +320,20 @@ class Preprocessor_DOM extends Preprocessor { } else { $found = 'line-start'; } + } elseif ( $curTwoChar == $currentClosing ) { + $found = 'close'; + $curChar = $curTwoChar; } elseif ( $curChar == $currentClosing ) { $found = 'close'; + } elseif ( isset( $this->rules[$curTwoChar] ) ) { + $curChar = $curTwoChar; + $found = 'open'; + $rule = $this->rules[$curChar]; } elseif ( isset( $this->rules[$curChar] ) ) { $found = 'open'; $rule = $this->rules[$curChar]; + } elseif ( $curChar == '-' ) { + $found = 'dash'; } else { # Some versions of PHP have a strcspn which stops on null characters # Ignore and continue @@ -595,7 +613,8 @@ class Preprocessor_DOM extends Preprocessor { // input pointer. } elseif ( $found == 'open' ) { # count opening brace characters - $count = strspn( $text, $curChar, $i ); + $curLen = strlen( $curChar ); + $count = ( $curLen > 1 ) ? 1 : strspn( $text, $curChar, $i ); # we need to add to stack only if opening brace count is enough for one of the rules if ( $count >= $rule['min'] ) { @@ -615,12 +634,13 @@ class Preprocessor_DOM extends Preprocessor { # Add literal brace(s) $accum .= htmlspecialchars( str_repeat( $curChar, $count ) ); } - $i += $count; + $i += $curLen * $count; } elseif ( $found == 'close' ) { $piece = $stack->top; # lets check if there are enough characters for closing brace $maxCount = $piece->count; - $count = strspn( $text, $curChar, $i, $maxCount ); + $curLen = strlen( $curChar ); + $count = ( $curLen > 1 ) ? 1 : strspn( $text, $curChar, $i, $maxCount ); # check for maximum matching characters (if there are 5 closing # characters, we will probably need only 3 - depending on the rules) @@ -643,7 +663,7 @@ class Preprocessor_DOM extends Preprocessor { # No matching element found in callback array # Output a literal closing brace and continue $accum .= htmlspecialchars( str_repeat( $curChar, $count ) ); - $i += $count; + $i += $curLen * $count; continue; } $name = $rule['names'][$matchingCount]; @@ -682,7 +702,7 @@ class Preprocessor_DOM extends Preprocessor { } # Advance input pointer - $i += $matchingCount; + $i += $curLen * $matchingCount; # Unwind the stack $stack->pop(); @@ -716,6 +736,9 @@ class Preprocessor_DOM extends Preprocessor { $stack->getCurrentPart()->eqpos = strlen( $accum ); $accum .= '='; ++$i; + } elseif ( $found == 'dash' ) { + $accum .= '-'; + ++$i; } }