-
Notifications
You must be signed in to change notification settings - Fork 96
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
Character escaping with \\
in a string
#45
Comments
Hey @jarrodek -- sorry for the late response! I was mid-merge of the 2.0 branch and wanted to wrap that before starting new tickets. I'm trying to wrap my head around this -- do you have code that reproduces the problem? It's unclear to me whether this is a multiline string that's being evaluated as a jexl expression, or whether this is being provided as the context and referenced from within a jexl expression. |
I also have some issues concerning the quote escaping with the 1.1.4 release. Here is a PoC showing the problem : var jexl = require('Jexl');
var jeval = function(e) {
console.log(e);
return jexl.eval(e);
}
jexl.addTransform("log", function(m) { console.log(m); });
jexl.addTransform("test", function(a, e) { return jeval(e); });
var instructions = "0|test('0|test(\\\'0|test(\\\\\'(\\\\\\\'message\\\\\\\')|log\\\\\')\\\')')";
jeval(instructions); You can see I added a layer above My code only fail if there are 3 (or more) imbrication levels. If there are less, the quotes are correctly escaped. Just test with |
OK I found where my problem was from. It is in the function r.prototype._unquote = function(e) {
var t = e[0],
r = new RegExp("\\\\" + t, "g");
return e.substr(1, e.length - 2).replace(r, t).replace(o, "\\"); // o = /\\\\/
} The So here is the corrected function : r.prototype._unquote = function(e) {
var t = e[0],
r = new RegExp("\\\\" + t, "g");
return e.substr(1, e.length - 2).replace(r, t);
} From what I understood of the original post, it seems that it would solve it too. |
Hi, |
This issue was reported by one of my users: advanced-rest-client/arc-electron#102
The user put the following text into the input:
The result of parsing it with Jexl is:
The problem is with
\\
characters in 1st and 2nd lines. They got truncated but only the first occurance. At first I thought it's my implementation but after tracing the execution it gets truncated when calling Jexl API.Is there something I can do to prevent this behavior? Or can it be fixed in Jexl?
Thanks
The text was updated successfully, but these errors were encountered: