elkarte/Elkarte — pull request #1066 by Spuds (2013-11-20 17:02:28+00:00)
Title: Updates to combine class for improved error robustness

This is a long story that I'll try and be short with.

I was finding that the combine.class was indirectly causing Apache to seg fault and restat, nothing in the error log but a 255 even with verbose settings. The result was the browser would show a connection reset page and not the web site.

The cause of this is kind of narrow, but windows, php5.4 will fail (*nix 5.4 is fine as well as windows 5.3), fun fun. What happens is that there is a regex in the jsminplus function that uses recursion, and on windows, given a long enough string, it consumes all the stack space, seg fault, restart.

Short of replacing the regex (and lacking good test cases for that function) I did a few things. One is prevent the seg fault on windows by limiting the recursion depth, so now jsminplus will simply generate an error which we can catch. I looked for other minify classes but could not find one I was happy with, plus this is a bit of a narrow case.

To further help, I set up the class to use the closure compiler api to do the minify action as well, So now it will first attempt to use closure with a single url request, failing that it will use jsminplus, failing that closure with a code post request(s), failing that just returns the original file. You can see the comments in the jsCompile function for further details.

Closure found several *soft* errors in the JS, so those files are part of this PR to allow it to minify with that service.

Tested with and without curl, seems to work fine.