From 3d6c28a9db409bd0c1aea4b30fb2af35f955a145 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Mon, 31 Jan 2011 12:48:08 +0000 Subject: [PATCH] (bug 27046) Do not strip newlines following C++-style // comments. Prior to this commit, such newlines were always stripped, causing invalid JS output in certain cases. They are now always preserved, even if they would normally qualifiy for vertical whitespace stripping/collapsing when wgResourceLoaderMinifyJSVerticalSpace is enabled. --- includes/libs/JavaScriptDistiller.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/libs/JavaScriptDistiller.php b/includes/libs/JavaScriptDistiller.php index ff2a0b2848..3e0a00f8fe 100644 --- a/includes/libs/JavaScriptDistiller.php +++ b/includes/libs/JavaScriptDistiller.php @@ -84,7 +84,8 @@ class JavaScriptDistiller { $parser->add( '/[^\\w\\$\\/\'"*)\\?:]\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?/', '$1' ); // Remove comments $parser->add( '/\\/\\*(.|[\\r\\n])*?\\*\\//' ); - $parser->add( '/\\/\\/[^\\r\\n]*[\\r\\n]/' ); + // Preserve the newline after a C++-style comment -- bug 27046 + $parser->add( '/\\/\\/[^\\r\\n]*([\\r\\n])/', '$2' ); return $parser; } } -- 2.20.1