Commit graph

19 commits

Author SHA1 Message Date
Roan Kattouw
5504fabee6 Remove comment that makes no sense post r82399 2011-02-18 14:21:52 +00:00
Tim Starling
707fe29c39 Fix comments and whitespace for \\\\ . 2011-02-18 14:18:26 +00:00
Tim Starling
a58fae8082 JavaScriptDistiller fixes:
* Removed some repeated subexpressions, /(.)*/ etc. These cause the stack space to be rapidly exhausted, leading to a segfault for malicious input. I replaced the ([\r\n]|.) subexpressions with a dot with a /s modifier. Added a pcre.recursion_limit hack to take care of the rest. 
* Supported assertions and non-capturing subpatterns in ParseMaster::add() by recognising that parentheses that aren't followed by "?" are capturing. Used another assertion to do this.
* Fixed a bug whereby if a single-line comment had a slash in it, it was recognised as a regex instead of a comment. This occurred because the leading whitespace caused the regex regex to match at an earlier string position than the comment regex, giving it undue precedence. This was the subject of several reports on IRC and the main reason for me starting work on JavaScriptDistiller. Used a lookbehind assertion.
* Give comments precedence over regexes and strings where there is ambiguity at the same string location. Not sure if this does anything, but it seemed like a good idea at the time.
* Removed unused variable ParseMaster::$TRIM.
* To test it, I ran the old and new jquery.js output through Google Closure Compiler. The result was the same, proving that there are no functional differences.
2011-02-18 14:09:03 +00:00
Sam Reed
2f8770f48b Comment out 2 unused lines in JavaScriptDistiller 2011-02-18 10:32:11 +00:00
Tim Starling
430f653e72 * For readability, use /x in regexes. Removed the start and end slashes from the input to ParseMaster::add(), to avoid confusion over the lack of a /x modifier in that input.
* Broke up several regexes and added comments, so that humans might be able to understand them.
* Tested md5(minify(jquery.js)) as before. Checked speed, it's the same.
2011-02-18 07:36:11 +00:00
Tim Starling
27981283a7 Made the regexes slightly more readable by undoubling the backslashes where possible. Tested by ensuring that the minifier output is the same before and after, with jquery.js as input. 2011-02-18 06:54:46 +00:00
Roan Kattouw
c1ba885db2 Fix a bug in string recognition in JSDistiller. This *really* fixes bug 27481 2011-02-17 22:36:11 +00:00
Roan Kattouw
12407cea19 Fix for r82344, which causes JSDistiller to stop minifying comments because it thought they were regexes. Make the regex regex a little bit stricter again, forbidding a regex from starting with * and other invalid things that were disallowed prior to r82344 (but still dropping / ) and forbidding multiline regexes 2011-02-17 22:07:18 +00:00
Roan Kattouw
e7a2f04176 Revert r82340, caused something linke bug 27481 where spaces were being wrongly collapsed. Fixed by changing regex to be more flexible in protecting regexes; nothing wrong with being overinclusive in what we're protecting 2011-02-17 19:19:50 +00:00
Roan Kattouw
e519eadc99 (bug 27492) Fix regexes for matching JS regexes which could get messed up by the minifier in extreme circumstances 2011-02-17 17:08:06 +00:00
Mark A. Hershberger
b4cee86beb w/s fixups 2011-02-12 04:06:22 +00:00
Roan Kattouw
158c26e49b Reimplement r80900, was lost when code was moved around 2011-02-08 10:26:30 +00:00
Roan Kattouw
3d6c28a9db (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. 2011-01-31 12:48:08 +00:00
Platonides
1f74392405 ParseMaster is designed to use big regexes, with many starting characters.
It makes sense to pcre_study() them.
2011-01-30 14:19:55 +00:00
Trevor Parscal
8d36f30802 Resolves bug 26931, where comments were not only not being properly stripped out, but were being transformed into syntax errors. 2011-01-25 19:00:21 +00:00
Trevor Parscal
2fcb86a6c6 Resolves issue in r80656 where escaped quotes within strings are not handled properly, resulting in the string being truncated. 2011-01-24 19:47:57 +00:00
Roan Kattouw
082620d2f4 Fix r80666: botched variable rename 2011-01-21 17:23:24 +00:00
Trevor Parscal
3fe1056d70 Addresses issues raised in an excellent review of r80656. 2011-01-21 00:03:58 +00:00
Trevor Parscal
951103eeb2 Resolved bug 26791 by replacing JSMin with a new library called JavaScriptDistiller, which is an improved version of the minification bits from JavaScriptPacker, an LGPL library. Good news - it's 2x faster than our optimized JSMin anyways, and more configurable to boot. 2011-01-20 21:57:01 +00:00