-
Notifications
You must be signed in to change notification settings - Fork 82
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
RemoveComments (JsSanitizer#checkBraces) fails if a string has an unescaped double quote in it #102
Comments
Hello @sebi88 - thank you for raising this issue. Could you provide a bit of background why you would need to remove the comments? Maybe this could help us come up with a workaround or come up with a good fix. Otherwise, can you spot anything obvious in the code that may be causing this: https://github.com/javadelight/delight-nashorn-sandbox/blob/146398c3a85935190ec59557499b5997f0b345ee/src/main/java/delight/nashornsandbox/internal/RemoveComments.java ? |
hi @mxro , thanks for checking the issue, the big picture is that this code snippet: public static void main(String[] args) throws ScriptCPUAbuseException, ScriptException, NoSuchMethodException {
NashornSandbox sandbox = NashornSandboxes.create();
sandbox.setExecutor(Executors.newSingleThreadExecutor());
String function = "function execute() {\n" +
"var output = {};\n" +
"var addOutput = function(name, value) {\n" +
" output[name] = value;\n" +
"};\n" +
"a = '\"'\n" +
"//something for testing\n" +
"addOutput(\"x\", a);" +
"return output;\n" +
"}";
sandbox.eval(function);
Invocable invocable = sandbox.getSandboxedInvocable();
Object result = invocable.invokeFunction("execute");
System.out.println(result);
} throws an exception:
Notice, that the The workaround is to set: |
☝️ The above is not the cleanest fix for the issue but appears to work for now. There appears to be something wrong with the logic to remove braces. If anyone would like to look into a better fix, pleas be welcome. Otherwise this is released now in |
thx! |
if value of
js
is:returns:
So RemoveComment's state machine loses the track.
This input works fine:
version: delight-nashorn-sandbox-0.1.26.jar
The text was updated successfully, but these errors were encountered: