Index: trunk/phase3/includes/libs/JavaScriptDistiller.php |
— | — | @@ -19,7 +19,6 @@ |
20 | 20 | * @param $stripVerticalSpace Boolean: Try to remove as much vertical whitespace as possible |
21 | 21 | */ |
22 | 22 | public static function stripWhiteSpace( $script, $stripVerticalSpace = false ) { |
23 | | - $script = self::stripComments( $script ); |
24 | 23 | $script = self::stripHorizontalSpace( $script ); |
25 | 24 | // If requested, make some vertical whitespace collapsing as well |
26 | 25 | if ( $stripVerticalSpace ) { |
— | — | @@ -29,15 +28,6 @@ |
30 | 29 | return $script; |
31 | 30 | } |
32 | 31 | |
33 | | - private static function stripComments( $script ) { |
34 | | - $parser = self::createParser(); |
35 | | - // Remove comments |
36 | | - $parser->add( '/\'([^\'\\\\]*(\\\\.[^\'\\\\]*)*)\'/', '$1' ); |
37 | | - $parser->add( '/"([^"\\\\]*(\\\\.[^"\\\\]*)*)"/', '$1' ); |
38 | | - // Execute and return |
39 | | - return $parser->exec( $script ); |
40 | | - } |
41 | | - |
42 | 32 | private static function stripHorizontalSpace( $script ) { |
43 | 33 | $parser = self::createParser(); |
44 | 34 | // Collapse horizontal whitespaces between variable names into a single space |
— | — | @@ -92,6 +82,9 @@ |
93 | 83 | // Protect regular expressions |
94 | 84 | $parser->add( '/[ \\t]+(\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?)/', '$2' ); |
95 | 85 | $parser->add( '/[^\\w\\$\\/\'"*)\\?:]\\/[^\\/\\r\\n\\*][^\\/\\r\\n]*\\/g?i?/', '$1' ); |
| 86 | + // Remove comments |
| 87 | + $parser->add( '/\\/\\*(.|[\\r\\n])*?\\*\\//' ); |
| 88 | + $parser->add( '/\\/\\/[^\\r\\n]*[\\r\\n]/' ); |
96 | 89 | return $parser; |
97 | 90 | } |
98 | 91 | } |