Skip to content

Commit a83f415

Browse files
authored
fix(devtools): escape newlines in logged queries (#257)
1 parent 1504d52 commit a83f415

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

devtools/src/devtools/lib/inspectedWindow.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@
66
// recent(ly) used element(s), assign an id to them, and then use messaging. But
77
// for now, this is way easier.
88

9+
function escape(str) {
10+
return str.replace(/'/g, "\\'").replace(/\n/g, '\\n');
11+
}
12+
913
function logQuery(query) {
1014
chrome.devtools.inspectedWindow.eval(`
11-
console.log('${query.replace(/'/g, "\\'")}');
15+
console.log('${escape(query)}');
1216
console.log(eval(${query}));
1317
`);
1418
}

0 commit comments

Comments
 (0)