Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 在视图中转义变量?_Node.js_Xss_Sql Injection - Fatal编程技术网

Node.js 在视图中转义变量?

Node.js 在视图中转义变量?,node.js,xss,sql-injection,Node.js,Xss,Sql Injection,我想知道如何在Node.js项目的视图中转义变量 例如,my.jade视图文件中的#{name}似乎容易受到SQL注入或XSS的攻击。有没有标准的方法来解决这个问题?我知道在ruby中,我会这样做,例如…出于某种原因,实际上想要{}?逃开! Actually want #{} for some reason? escape it! p \#{something} now we have <p>#{something}</p> We can also utilize t

我想知道如何在Node.js项目的视图中转义变量

例如,my.jade视图文件中的#{name}似乎容易受到SQL注入或XSS的攻击。有没有标准的方法来解决这个问题?我知道在ruby中,我会这样做,例如…

出于某种原因,实际上想要{}?逃开!
Actually want #{} for some reason? escape it!

p \#{something}
now we have <p>#{something}</p>

We can also utilize the unescaped variant !{html}, so the following will result in a literal script tag:

- var html = "<script></script>"
| !{html}
p\{something} 现在我们有了{something}

我们还可以使用未经scaped的变体!{html},因此以下内容将生成文字脚本标记: -var html=“” | !{html}

IIRC,默认情况下Jade会转义。是的,默认情况下Jade会转义,请使用!{}如果你不想逃跑,我明白了。(message是一个变量):p=message p#{message}变量message和#{message}是相同的,这取决于您在哪里/如何使用它们。下面的文章帮助了我