mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-27 09:09:04 +01:00
allow expressions to end in a $ eg. in PHP "test$" is valid, no longer throwing an error if expression cant be parsed, just log the error and return expression literally
This commit is contained in:
parent
420234cb46
commit
efa9c562bb
@ -64,6 +64,12 @@
|
|||||||
str += '$$';
|
str += '$$';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// check for '$' as last char, as in PHP "test$" === 'test$', $ as last char is NOT expanded
|
||||||
|
if (_p.pos == _p.expr.length)
|
||||||
|
{
|
||||||
|
str += '$';
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (str)
|
if (str)
|
||||||
{
|
{
|
||||||
_tree.push(str); str = "";
|
_tree.push(str); str = "";
|
||||||
@ -401,21 +407,28 @@
|
|||||||
_vars = [];
|
_vars = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the parser object and create the syntax tree for the given
|
try {
|
||||||
// expression
|
// Initialize the parser object and create the syntax tree for the given
|
||||||
var parser = _php_parser(_expr);
|
// expression
|
||||||
|
var parser = _php_parser(_expr);
|
||||||
|
|
||||||
var syntaxTree = [];
|
var syntaxTree = [];
|
||||||
|
|
||||||
// Parse the given expression as if it was a double quoted string
|
// Parse the given expression as if it was a double quoted string
|
||||||
_php_parseDoubleQuoteString(parser, syntaxTree);
|
_php_parseDoubleQuoteString(parser, syntaxTree);
|
||||||
|
|
||||||
// Transform the generated syntaxTree into a JS string
|
// Transform the generated syntaxTree into a JS string
|
||||||
var js = _php_compileJSCode(_vars, syntaxTree);
|
var js = _php_compileJSCode(_vars, syntaxTree);
|
||||||
|
|
||||||
// Log the successfull compiling
|
|
||||||
egw.debug("log", "Compiled PHP " + _expr + " --> " + js);
|
|
||||||
|
|
||||||
|
// Log the successfull compiling
|
||||||
|
egw.debug("log", "Compiled PHP " + _expr + " --> " + js);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
// if expression does NOT compile use it literally and log an error, but not stop execution
|
||||||
|
egw.debug("error", "Error compiling PHP "+_expr+" --> using it literally ("+
|
||||||
|
(typeof e == 'string' ? e : e.message)+")!");
|
||||||
|
return function(){ return _expr; };
|
||||||
|
}
|
||||||
// Prepate the attributes for the function constuctor
|
// Prepate the attributes for the function constuctor
|
||||||
var attrs = [];
|
var attrs = [];
|
||||||
for (var i = 0; i < _vars.length; i++)
|
for (var i = 0; i < _vars.length; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user