简体   繁体   中英

Internet explorer 9 issue with escaping double quotes javascript

Below is my case: var sql = 'INSERT INTO \\"template_items\\" (\\"item\\") VALUES (\\"0a\\")';

alert(sql) gives below value:

INSERT INTO "template_items" ("item") VALUES ("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

"INSERT INTO \\"template_items\\" (\\"item\\") VALUES (\\"0a\\")"

Backslash is still there.

Now this is creating problem when i use variable sql in below statements:

connection.BeginTrans();

connection.Execute(sql);

connection.CommitTrans();

What is the solution to this problem?

First off; You should NEVER make SQL in the frontend!!! 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)

In case anybody else is facing same issue,

[accessdb.js][1] works good.

I debugged this and found recordset.open missed some parameters .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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