X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fparser%2FPreprocessor_Hash.php;h=4f04c86502c319b53a69cea30312f63c45077d69;hb=1a9b7b2238c4da398a06ac89fbe2cd418be42e6e;hp=9296e3f10f0f4b82581aa67ce323f12e2242e942;hpb=dbd9e5559c51ba03cc77fa06226be1978a3a647b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/parser/Preprocessor_Hash.php b/includes/parser/Preprocessor_Hash.php index 9296e3f10f..4f04c86502 100644 --- a/includes/parser/Preprocessor_Hash.php +++ b/includes/parser/Preprocessor_Hash.php @@ -177,6 +177,7 @@ class Preprocessor_Hash implements Preprocessor { $searchBase = "[{<\n"; $revText = strrev( $text ); // For fast reverse searches + $lengthText = strlen( $text ); $i = 0; # Input pointer, starts out pointing to a pseudo-newline before the start $accum =& $stack->getAccum(); # Current accumulator @@ -231,7 +232,7 @@ class Preprocessor_Hash implements Preprocessor { $accum->addLiteral( substr( $text, $i, $literalLength ) ); $i += $literalLength; } - if ( $i >= strlen( $text ) ) { + if ( $i >= $lengthText ) { if ( $currentClosing == "\n" ) { // Do a past-the-end run to finish off the heading $curChar = ''; @@ -295,10 +296,10 @@ class Preprocessor_Hash implements Preprocessor { // Unclosed comment in input, runs to end $inner = substr( $text, $i ); $accum->addNodeWithText( 'comment', $inner ); - $i = strlen( $text ); + $i = $lengthText; } else { // Search backwards for leading whitespace - $wsStart = $i ? ( $i - strspn( $revText, ' ', strlen( $text ) - $i ) ) : 0; + $wsStart = $i ? ( $i - strspn( $revText, ' ', $lengthText - $i ) ) : 0; // Search forwards for trailing whitespace // $wsEnd will be the position of the last space (or the '>' if there's none) $wsEnd = $endPos + 2 + strspn( $text, ' ', $endPos + 3 ); @@ -383,7 +384,7 @@ class Preprocessor_Hash implements Preprocessor { } else { // No end tag -- let it run out to the end of the text. $inner = substr( $text, $tagEndPos + 1 ); - $i = strlen( $text ); + $i = $lengthText; $close = null; } } @@ -447,16 +448,16 @@ class Preprocessor_Hash implements Preprocessor { $part = $piece->getCurrentPart(); // Search back through the input to see if it has a proper close // Do this using the reversed string since the other solutions (end anchor, etc.) are inefficient - $wsLength = strspn( $revText, " \t", strlen( $text ) - $i ); + $wsLength = strspn( $revText, " \t", $lengthText - $i ); $searchStart = $i - $wsLength; if ( isset( $part->commentEnd ) && $searchStart - 1 == $part->commentEnd ) { // Comment found at line end // Search for equals signs before the comment $searchStart = $part->visualEnd; - $searchStart -= strspn( $revText, " \t", strlen( $text ) - $searchStart ); + $searchStart -= strspn( $revText, " \t", $lengthText - $searchStart ); } $count = $piece->count; - $equalsLength = strspn( $revText, '=', strlen( $text ) - $searchStart ); + $equalsLength = strspn( $revText, '=', $lengthText - $searchStart ); if ( $equalsLength > 0 ) { if ( $searchStart - $equalsLength == $piece->startPos ) { // This is just a single string of equals signs on its own line