Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_ucmp() fails for specific contents #703

Closed
ktrzeciaknubisa opened this issue Dec 9, 2015 · 1 comment
Closed

_ucmp() fails for specific contents #703

ktrzeciaknubisa opened this issue Dec 9, 2015 · 1 comment

Comments

@ktrzeciaknubisa
Copy link
Member

Since we're getting rid of base64 encoding when passing strings/buffers to _cmp() / _ucmp() (due to #508) I've encountered one file for which _ucmp() fails (returns false).

This is a xml file and comes from one of ghost's sub modules (sax). It's better to download the file rather than copy/paste to editor.

jx install sax@0.4.2
# the file is under node_modules/sax/examples/big-not-pretty.xml

Then the following code shows the problem:

var jxt = process.binding('jxutils_wrap');
var fs = require('fs');

var input = fs.readFileSync('./node_modules/sax/examples/big-not-pretty.xml');
var c = jxt._cmp(input);
var output = jxt._ucmp(c);

if (!output)
  jxcore.utils.console.error('Empty output!');

Not really sure what is the problem. I was stripping the file to make it smaller, and so I arrived to the point of this big-not-pretty2.zip (the file is compressed in order to preserve binary format - unzip before use), where removing single (literally any) character from file contents makes the above code work. But the problem is not related to file size, because _ucmp() is working with much bigger files.

@ktrzeciaknubisa
Copy link
Member Author

I've also found, that the following files from jxcore repo also have this problems. What came to my eyes is that each of those files contain series of repetitive strings/blocks, for example:

  1. ./deps/mozjs/src/tests/js1_5/Regress/regress-229006.js

    has multiple empty lines following each other

  2. ./deps/mozjs/src/jit-test/tests/basic/bug586917 and
    ./deps/mozjs/src/tests/js1_5/Regress/regress-311629.js

        try {} catch (e) {}
        try {} catch (e) {}
        try {} catch (e) {}
        try {} catch (e) {}
  3. ./deps/mozjs/src/tests/js1_5/Regress/regress-229006.js

    eval('+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +  ...
  4. ./deps/npm/node_modules/request/node_modules/form-data/node_modules/combined-stream/test/fixture/file1.txt

    101010101010101010101010101010101010101010101010101010101010
    
  5. ./deps/npm/node_modules/request/node_modules/form-data/node_modules/combined-stream/test/fixture/file2.txt

    2020202020202020202020202020202020202020202020202020202020202
    
  6. ./test/fixtures/elipses.txt

    ………………………………………………………………………………
    

    The xml mentioned earlier (big-not-pretty.xml) also contains repetitive blocks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant