PDA

View Full Version : Yui Compressor, Obfuscation Errors



ferr
27 Feb 2008, 8:16 AM
I've been trying to find an obfuscator for my JS files and am having some trouble with the ones I've tested. Specifically with Yuicompressor I receive syntax errors during obfuscation:

... yuicompressor-2.3.4.jar" "C:\obf tests\Copy of testpreobf1.js"

[ERROR] 1:2:illegal character

[ERROR] 1:2:syntax error

[ERROR] 1:3:illegal character

[ERROR] 1:0:Compilation produced 3 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 3 syntax errors.

at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICom
pressor.java:143)
at org.mozilla.javascript.Parser.parse(Parser.java:402)
at org.mozilla.javascript.Parser.parse(Parser.java:347)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScri
ptCompressor.java:312)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScr
iptCompressor.java:532)
at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.ja
va:120)
Can anything be derived from this error message? I have no clue as to what it's complaining about.

I ran the same JS code through JSLint and the only errors I received were nothing more than warnings such as line breaks and missing '{' for one-line if-statements.

Can anyone suggest a similar (perhaps free?) obfuscator/minifier that is a bit more flexible or at least a bit more detailed in its errors?

mystix
27 Feb 2008, 8:23 AM
woah... YUICompressor's the best one i know of...

i've never seen those errors before btw.

try removing those spaces from your js file's filename for starters.

p.s. version 2.3.5 is already out. couple of bugfixes made it into this version.
p.s.s. if you could post a little snippet of that file i could run it through my yuicompressor and see what it turns up.

ferr
27 Feb 2008, 8:27 AM
I'm in a bit of disbelief. Found something called Javascript-Obfuscator from javascript-source and it worked flawlessly (has a price tag, but that's ok..). I wonder why J-O has no issues but YUI Compressor freaks out? I put the obfuscated code into my project and it runs perfectly. Went from 36k to 22k and that was at the default obfuscation settings (no variable name changes).

Animal
27 Feb 2008, 8:41 AM
Don't post here about it, tell the author!

http://www.julienlecomte.net/blog/

mystix
27 Feb 2008, 8:45 AM
if i may be allowed one last post :D

@ferr, yuicompressor isn't exactly an obfuscator per se, but it sure as heck does a fantastic job of compressing code and checking for errors. be sure to drop a bug report @ the YUI sourceforge site for yuicompressor. i filed one bug and the author had it fixed within the week.

CPliskin
27 Feb 2008, 12:00 PM
[ERROR] 1:2:illegal character

[ERROR] 1:2:syntax error

[ERROR] 1:3:illegal character

[ERROR] 1:0:Compilation produced 3 syntax errors.


I had same issues on < 2.3 revisions of yui-compressor. It was encoding issue in my case.
Try to add "--charset utf-8" or replace utf-8 with appropriate encoding.

ferr
27 Feb 2008, 2:06 PM
I had same issues on < 2.3 revisions of yui-compressor. It was encoding issue in my case.
Try to add "--charset utf-8" or replace utf-8 with appropriate encoding.

That option worked for me. And YUI-C gave me an increase in reduction versus J-O by about 15% thanks to the automatic local variable renaming.. and it's free! thanks!