简体   繁体   English

带有双引号javascript的Internet Explorer 9问题

[英]Internet explorer 9 issue with escaping double quotes javascript

Below is my case: var sql = 'INSERT INTO \\"template_items\\" (\\"item\\") VALUES (\\"0a\\")'; 下面是我的情况:var sql ='INSERT INTO \\“ template_items \\”(\\“ item \\”)VALUES(\\“ 0a \\”)';;

alert(sql) gives below value: alert(sql)给出以下值:

INSERT INTO "template_items" ("item") VALUES ("0a") 插入“ template_items”(“ item”)值(“ 0a”)
which is correct and shows correct escaping of double quotes. 这是正确的,并显示正确的双引号转义。

But when variable sql is viewed in IE9 debugger(F12) below is its value 但是当在IE9调试器(F12)中查看变量sql时,其值是

"INSERT INTO \\"template_items\\" (\\"item\\") VALUES (\\"0a\\")" “将INERT插入\\“ template_items \\”(\\“ item \\”)值(\\“ 0a \\”)“

Backslash is still there. 反斜杠仍然存在。

Now this is creating problem when i use variable sql in below statements: 现在,当我在以下语句中使用变量sql时,这会造成问题:

connection.BeginTrans(); connection.BeginTrans();

connection.Execute(sql); connection.Execute(SQL);

connection.CommitTrans(); connection.CommitTrans();

What is the solution to this problem? 这个问题有什么解决方案?

First off; 首先 You should NEVER make SQL in the frontend!!! 永远不要在前端使用SQL !!! It's a HUGE security hole! 这是一个巨大的安全漏洞!

Second: To fix the problem in your console you could use single quotes around your text and double inside: var text = 'some " quotes " in " text' (but this shouldn't be a problem when the backend receives your string) 第二:要解决控制台中的问题,您可以在文本周围使用单引号,并在内部使用双引号: var text = 'some " quotes " in " text' (但是当后端收到您的字符串时,这应该不是问题)

In case anybody else is facing same issue, 如果其他人面临同样的问题,

[accessdb.js][1] works good. [accessdb.js] [1]效果很好。

I debugged this and found recordset.open missed some parameters . 我对此进行了调试,发现recordset.open缺少一些参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM