Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix modifying of reserved strings#442

Closed
ghost wants to merge 2 commits into
masterjavascript-obfuscator/javascript-obfuscator:masterfrom
unknown repositoryCopy head branch name to clipboard
Closed

Fix modifying of reserved strings#442
ghost wants to merge 2 commits into
masterjavascript-obfuscator/javascript-obfuscator:masterfrom
unknown repositoryCopy head branch name to clipboard

Conversation

@ghost

@ghost ghost commented Dec 2, 2019

Copy link
Copy Markdown

Changed isReservedString from private to public on StringLiteralObfuscatingReplacer and added check for reserved strings before calling replace.

I do not fully understand what the StringLiteralObfuscatingReplacer is doing (did not spend that much time in the code) but it seems it will modify strings in the code even if they are included in reservedStrings options.

I am creating this PR because we want to use this library in react-native project but when this is modifying reserver strings it will crash our application it wont even start. With this "fix" it works.

Please take a look, it is kind of modifying the output produced by this library, but only 1 test was failing so not sure what impact it can have. Thank you

@coveralls

coveralls commented Dec 2, 2019

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.05%) to 97.933% when pulling 14a6550 on dusan-dragon:fix/string-replacer into 2ff9f2c on javascript-obfuscator:master.

@zamotkin

zamotkin commented Dec 2, 2019

Copy link
Copy Markdown
Contributor

@dusan-dragon thanks for commit! Could you attach an example of code or (better) a test case that works only with your fix?

@sanex3339

Copy link
Copy Markdown
Member

Current output on obfuscator.io is

const foo='foo\x20baz';

@ghost

ghost commented Dec 2, 2019

Copy link
Copy Markdown
Author

Added test which fails on master but passes on this branch

@ghost

ghost commented Dec 2, 2019

Copy link
Copy Markdown
Author

@zamotkin I will try but not sure If I will be able to create such an example as the current obfuscated code is quite complicated and we use more general regex for reserved strings as narrowing down what exactly is the issue is taking too much time

@zamotkin

zamotkin commented Dec 2, 2019

Copy link
Copy Markdown
Contributor

@dusan-dragon sorry, I can't understand what issue you are trying to solve, I need more details.

@ghost

ghost commented Dec 3, 2019

Copy link
Copy Markdown
Author

I do not know what is exactly the issue but my obfuscated code will not run without this in react native.
So far I narrowed down that there is something wrong if strings which starts with non alphanumeric characters get transformed with this function without my modification, I know that because I use:
"reservedStrings": ["^[^a-zA-Z0-9].*$"], - if I modify that regex to match only strings starting with alphanumerical characters then even this PR does not help...

@sanex3339

Copy link
Copy Markdown
Member

Thank you for the PR. I'll reimplement this fix in slightly different way, to work with other literal transformers, so, i'll close this PR in favor of my pr

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

Successfully merging this pull request may close these issues.

4 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.