From f694e2d37f34425761ace0c9b9cbf14c55c3f226 Mon Sep 17 00:00:00 2001 From: bitWolfy Date: Wed, 8 Apr 2020 23:00:38 -0700 Subject: [PATCH] Hotfix: crash caused by malformed blacklist JSON Fixes #146 --- src/js/components/data/User.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/components/data/User.ts b/src/js/components/data/User.ts index 1676e420..351215b6 100644 --- a/src/js/components/data/User.ts +++ b/src/js/components/data/User.ts @@ -27,11 +27,13 @@ export class User { this.userid = parseInt($ref.attr("data-user-id")) || 0; this.level = $ref.attr("data-user-level-string") || "Guest"; - const filters = JSON.parse($("head meta[name=blacklisted-tags]").attr("content")); + const filters = $("head meta[name=blacklisted-tags]").attr("content"); const blacklistEnabled = $("#disable-all-blacklists").is(":visible"); - for (const filter of filters) { - this.addBlacklistFilter(filter, blacklistEnabled); + if (filters !== undefined) { + for (const filter of JSON.parse(filters)) { + this.addBlacklistFilter(filter, blacklistEnabled); + } } }