mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-15 12:15:20 +08:00
Secure ko template bindings?
This commit is contained in:
parent
cb9e1b0705
commit
904a353bff
1 changed files with 9 additions and 0 deletions
|
@ -36,6 +36,15 @@ ko.bindingProvider = new class
|
||||||
// For each scope variable, add an extra level of "with" nesting
|
// For each scope variable, add an extra level of "with" nesting
|
||||||
// Example result: with(sc1) { with(sc0) { return (expression) } }
|
// Example result: with(sc1) { with(sc0) { return (expression) } }
|
||||||
// Deprecated: with is no longer recommended
|
// Deprecated: with is no longer recommended
|
||||||
|
/*
|
||||||
|
functionBody = "$context = new Proxy(
|
||||||
|
$context,
|
||||||
|
{
|
||||||
|
has:()=>true,
|
||||||
|
get:(target,key)=>Reflect.has(target, key) ? target[key] : target['$data'][key]
|
||||||
|
}
|
||||||
|
);with($context){return{" + rewrittenBindings + "}}";
|
||||||
|
*/
|
||||||
var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString),
|
var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString),
|
||||||
functionBody = "with($data){return{" + rewrittenBindings + "}}";
|
functionBody = "with($data){return{" + rewrittenBindings + "}}";
|
||||||
bindingFunction = new Function("$context", "$root", "$parent", "$data", "$element", functionBody);
|
bindingFunction = new Function("$context", "$root", "$parent", "$data", "$element", functionBody);
|
||||||
|
|
Loading…
Reference in a new issue