Skip to content

Commit 02da198

Browse files
committed
fix: html escaping for console page
1 parent cd502d4 commit 02da198

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,4 @@
119119
"yargs": "^17.7.2"
120120
},
121121
"browserslist": "cover 100%,not android < 5"
122-
}
122+
}

src/lib/console.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ import loadPolyFill from "utils/polyfill";
468468
);
469469
break;
470470
default:
471-
$msg.innerHTML = arg;
471+
$msg.textContent = arg;
472472
break;
473473
}
474474
}
@@ -494,7 +494,7 @@ import loadPolyFill from "utils/polyfill";
494494
* @returns
495495
*/
496496
function format(args) {
497-
if (args.length <= 1) return [escapeHTML(args[0])];
497+
if (args.length <= 1) return [args[0]];
498498

499499
const originalArgs = [].concat(args);
500500
const styles = [];
@@ -548,8 +548,10 @@ import loadPolyFill from "utils/polyfill";
548548
break;
549549
}
550550
}
551-
msg = msg.substring(0, pos) + escapeHTML(value) + msg.substring(pos + 2);
552-
matched = matchRegex(msg);
551+
// Only escape HTML for the %o/%O case where we're injecting actual HTML
552+
const escapedValue = specifier === "%o" || specifier === "%O" ? value : escapeHTML(value);
553+
msg = msg.substring(0, pos) + escapedValue + msg.substring(pos + 2);
554+
matched = matchRegex(msg);
553555
}
554556

555557
if (styles.length) {

0 commit comments

Comments
 (0)