JavaScriptDistiller fixes:
authorTim Starling <tstarling@users.mediawiki.org>
Fri, 18 Feb 2011 14:09:03 +0000 (14:09 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Fri, 18 Feb 2011 14:09:03 +0000 (14:09 +0000)
commita58fae80826f59323665664f3d5f93a6b311b2d4
tree2843673d247f4757be16fbc7740eea458848d5b2
parent683fb93ee2cc5f63fb52a6fedb3fae1e9cdff8e6
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.
includes/libs/JavaScriptDistiller.php