From f41e2ddb6a0cdc6f7c32355215ffb25e907ba081 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Tue, 27 Jan 2015 06:02:56 +0000 Subject: [PATCH] Don't split regex string unnecessarily Change-Id: Id5912e64916ce5c7be2991478c32531596917540 --- includes/parser/Parser.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index fc7040a0e1..46ba4b4742 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -4384,7 +4384,7 @@ class Parser { # links - this is for later, but we need the number of headlines right now $matches = array(); $numMatches = preg_match_all( - '/[1-6])(?P.*?' . '>)\s*(?P
[\s\S]*?)\s*<\/H[1-6] *>/i', + '/[1-6])(?P.*?>)\s*(?P
[\s\S]*?)\s*<\/H[1-6] *>/i', $text, $matches ); @@ -4538,8 +4538,8 @@ class Parser { # to allow setting directionality in toc items. $tocline = preg_replace( array( - '#<(?!/?(span|sup|sub|bdi|i|b)(?: [^>]*)?>).*?' . '>#', - '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|bdi|i|b))(?: .*?)?' . '>#' + '#<(?!/?(span|sup|sub|bdi|i|b)(?: [^>]*)?>).*?>#', + '#<(/?(?:span(?: dir="(?:rtl|ltr)")?|sup|sub|bdi|i|b))(?: .*?)?>#' ), array( '', '<$1>' ), $safeHeadline @@ -4547,7 +4547,7 @@ class Parser { $tocline = trim( $tocline ); # For the anchor, strip out HTML-y stuff period - $safeHeadline = preg_replace( '/<.*?' . '>/', '', $safeHeadline ); + $safeHeadline = preg_replace( '/<.*?>/', '', $safeHeadline ); $safeHeadline = Sanitizer::normalizeSectionNameWhitespace( $safeHeadline ); # Save headline for section edit hint before it's escaped @@ -4715,7 +4715,7 @@ class Parser { } # split up and insert constructed headlines - $blocks = preg_split( '/[\s\S]*?<\/H[1-6]>/i', $text ); + $blocks = preg_split( '/[\s\S]*?<\/H[1-6]>/i', $text ); $i = 0; // build an array of document sections -- 2.20.1