Hi group

Recently while debugging, I went back to fastmail.com, which we improved around December. At one point I got a completely opaque message about a jquery error:
execute core-1.js at 1
TypeError: $(...) is null

I decided to bite the bullet and do something about this. When JS code is minified and compacted, the line numbers tell you nothing. It could report an error on line 1, but line 1 is several pages long.

So, I went back to a deobfuscator script that Chris and Karl sent me a link for last year. It will space things out, indent and add newlines. The symbols still suck, however now the line number of an error can be way more helpful. The deobfuscator is in Python so I pieced together how to embed the python interpreter and call it from C. And it works!! Chunks of JS code from a page get newlines!

Currently I have this in prepareScript. May not be the best place. I want to do it prior to when the line count is found.

Near the end of prepareScript, instead of:
        set_property_string(t->jv, "data", js_text);
I changed it to
        set_property_string(t->jv, "data", deobfuscate(js_text));


I can give you this proof of concept code if you like- at the minimum, it is going to help me isolate more DOM errors. I don't think it would be something that we would consider for the live edbrowse. UNLESS - is there any reason to believe that putting JS code through a deobfuscator is not isomorphic? Could it actually improve (or, change for the worse, unfortunately) the interpretation of the JS itself? I am surprised to find that when I rerun fastmail, I don't get the TypeError at all. I could be misinterpreting what I'm observing. Deobfuscation should be only a formatting change, but then, the python deobfuscator is a bunch of idiosyncratic decoders that people have handwritten for the output of the top five or six encoders, so I don't really know the algorithms and regular expressions they have used. It might modify the code as it reformats it.

This is the link to the beautifier:
https://github.com/beautify-web/js-beautify

Kevin

_______________________________________________
Edbrowse-dev mailing list
[email protected]
http://lists.the-brannons.com/mailman/listinfo/edbrowse-dev

Reply via email to