Skip to content

Fixes JS minification #342

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

Conversation

nwaldispuehl
Copy link
Contributor

@nwaldispuehl nwaldispuehl commented Apr 21, 2025

Fixes minified JavaScript (JS) by preventing token strings (e.g. %MY_TOKEN%) from being evaluated to true right away during JS minifcation.

Closes #341.

To customize the JS code during runtime we string-replace config tokens of the form '%MY_TOKEN%' when serving them to the client via the JavaScriptServlet class. Now during the newly introduced JS-minification these tokens were interpreted as true which broke this configuration injection. We now declare them as constants which prevents the evaluation.


So we found in our project that the minified JS does not behave as the conventional JS as described in #341.
This is an attempt to restore this replacement token functionality in the minified JS.
What do you think?

Reproduction

To perform the JS minification use this command from the project root:

$ mvn clean package -P minify-js

…_TOKEN%`) from being evaluated to `true` right away during JS minifcation. Closes OWASP#341.

To customize the JS code during runtime we string-replace config tokens of the form `'%MY_TOKEN%'` when serving them to the client via the `JavaScriptServlet` class. Now during the newly introduced JS-minification these tokens were interpreted as `true` which broke this configuration injection. We now declare them as constants which prevents the evaluation.
@forgedhallpass forgedhallpass merged commit 1118261 into OWASP:master Aug 5, 2025
@forgedhallpass
Copy link
Member

@nwaldispuehl nice catch and thank you for your contribution!

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.

Minified JavaScript file (csrfguard.min.js) behaves differently than non-minified version (csrfguard.js)
2 participants