Skip to content
Permalink
Browse files
Fix potential exception when casting to string
Related discussion:
- uBlockOrigin/uAssets#9123 (comment)

Related commits:
- gorhill/uBlock@07d3c96

Co-authored-by: Raymond Hill <rhill@raymondhill.net>
  • Loading branch information
JustOff and gorhill committed Jun 11, 2021
1 parent 3afe893 commit caa31f596e294b172ffc4e43ad9baa4525191559
Showing with 14 additions and 4 deletions.
  1. +14 −4 assets/resources/resources.txt
@@ -1493,15 +1493,20 @@ setInterval-logger.js application/javascript


# https://github.com/uBlockOrigin/uAssets/issues/521
# https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120
addEventListener-logger.js application/javascript
(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('addEventListener("%s", %s)', type, handler);
return target.apply(thisArg, args);
}
@@ -1619,6 +1624,7 @@ json-prune.js application/javascript


# https://github.com/uBlockOrigin/uAssets/issues/521
# https://github.com/uBlockOrigin/uAssets/issues/9123#issuecomment-848255120
addEventListener-defuser.js application/javascript
(function() {
let needle1 = '{{1}}';
@@ -1643,8 +1649,12 @@ addEventListener-defuser.js application/javascript
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

0 comments on commit caa31f5

Please sign in to comment.