(bug 27492) Fix regexes for matching JS regexes which could get messed up by the...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 17 Feb 2011 17:08:06 +0000 (17:08 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 17 Feb 2011 17:08:06 +0000 (17:08 +0000)
includes/libs/JavaScriptDistiller.php

index 91d330b..6ddaf8d 100644 (file)
@@ -80,8 +80,8 @@ class JavaScriptDistiller {
                $parser->add( '/\'([^\'\\\\]*(\\\\.[^\'\\\\]*)*)\'/', '$1' );
                $parser->add( '/"([^"\\\\]*(\\\\.[^"\\\\]*)*)"/', '$1' );
                // Protect regular expressions
-               $parser->add( '/[ \\t]+(\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?)/', '$2' );
-               $parser->add( '/[^\\w\\$\\/\'"*)\\?:]\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?/', '$1' );
+               $parser->add( '/([ \\t]+(\\/(?=[^\\/\\r\\n\\*])[^\\/\\\\]*(\\\\.[^\\/\\\\]*)*\\/(i|g)*))/', '$1' );
+               $parser->add( '/([^\\w\\$\\/\'"*)\\?:](\\/(?=[^\\/\\r\\n\\*])[^\\/\\\\]*(\\\\.[^\\/\\\\]*)*\\/(i|g)*))/', '$1' );
                // Remove comments
                $parser->add( '/\\/\\*(.|[\\r\\n])*?\\*\\//' );
                // Preserve the newline after a C++-style comment -- bug 27046