1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-05 11:37:01 +02:00

Fix potential exception when casting to string

Related discussion:
- https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120
This commit is contained in:
Raymond Hill 2021-05-26 07:22:17 -04:00
parent 7508700892
commit 07d3c96261
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -307,6 +307,7 @@
/// addEventListener-defuser.js
/// alias aeld.js
// https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120
(function() {
let needle1 = '{{1}}';
if ( needle1 === '' || needle1 === '{{1}}' ) {
@ -330,8 +331,12 @@
self.EventTarget.prototype.addEventListener,
{
apply: function(target, thisArg, args) {
const type = String(args[0]);
const handler = String(args[1]);
let type, handler;
try {
type = String(args[0]);
handler = String(args[1]);
} catch(ex) {
}
if (
needle1.test(type) === false ||
needle2.test(handler) === false
@ -346,14 +351,19 @@
/// addEventListener-logger.js
/// alias aell.js
// https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120
(function() {
const log = console.log.bind(console);
self.EventTarget.prototype.addEventListener = new Proxy(
self.EventTarget.prototype.addEventListener,
{
apply: function(target, thisArg, args) {
const type = String(args[0]);
const handler = String(args[1]);
let type, handler;
try {
type = String(args[0]);
handler = String(args[1]);
} catch(ex) {
}
log('uBO: addEventListener("%s", %s)', type, handler);
return target.apply(thisArg, args);
}