From 0d3b32a10d27fe642cdc90b5059fa6218e30989d Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Thu, 9 Jul 2020 15:56:09 -0500 Subject: [PATCH 1/3] Prevent malformed URLs from loading current tab --- src/services/cipher.service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index 7b519a1a4f..93d5a1fbcd 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -333,9 +333,12 @@ export class CipherService implements CipherServiceAbstraction { this.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => { let matches: any[] = []; eqDomains.forEach((eqDomain) => { - if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { - matches = matches.concat(eqDomain); + try { + if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { + matches = matches.concat(eqDomain); + } } + catch {} }); if (!matches.length) { From ebaa69a15bc220bf87208dfc673078ea3ad08316 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Thu, 9 Jul 2020 15:59:45 -0500 Subject: [PATCH 2/3] Formatting change. Inlined catch. --- src/services/cipher.service.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index 93d5a1fbcd..eaf1ec0f83 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -337,8 +337,7 @@ export class CipherService implements CipherServiceAbstraction { if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { matches = matches.concat(eqDomain); } - } - catch {} + } catch {} }); if (!matches.length) { From 57649f31c4b1ef210e4070f7e031758a9de4ee19 Mon Sep 17 00:00:00 2001 From: Matt Smith Date: Fri, 10 Jul 2020 10:01:15 -0500 Subject: [PATCH 3/3] Moved error checking to utils, where parse is --- src/misc/utils.ts | 11 ++++++++--- src/services/cipher.service.ts | 8 +++----- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/misc/utils.ts b/src/misc/utils.ts index e0b7041356..e9b8b4911d 100644 --- a/src/misc/utils.ts +++ b/src/misc/utils.ts @@ -204,9 +204,14 @@ export class Utils { } catch (e) { } } - const domain = tldjs != null && tldjs.getDomain != null ? tldjs.getDomain(uriString) : null; - if (domain != null) { - return domain; + try { + const domain = tldjs != null && tldjs.getDomain != null ? tldjs.getDomain(uriString) : null; + + if (domain != null) { + return domain; + } + } catch { + return null; } return null; diff --git a/src/services/cipher.service.ts b/src/services/cipher.service.ts index eaf1ec0f83..7b519a1a4f 100644 --- a/src/services/cipher.service.ts +++ b/src/services/cipher.service.ts @@ -333,11 +333,9 @@ export class CipherService implements CipherServiceAbstraction { this.settingsService.getEquivalentDomains().then((eqDomains: any[][]) => { let matches: any[] = []; eqDomains.forEach((eqDomain) => { - try { - if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { - matches = matches.concat(eqDomain); - } - } catch {} + if (eqDomain.length && eqDomain.indexOf(domain) >= 0) { + matches = matches.concat(eqDomain); + } }); if (!matches.length) {