From 960d51690f98197767b358ac8ce228bd2a88b4cc Mon Sep 17 00:00:00 2001 From: moisseev Date: Tue, 10 Dec 2019 10:51:24 +0300 Subject: [PATCH] Fix conditionals to avoid error on destructuring a `null` value when the header is broken. --- chrome/content/scripts/messageHeader.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/chrome/content/scripts/messageHeader.js b/chrome/content/scripts/messageHeader.js index 900b41d..2ac2ef1 100644 --- a/chrome/content/scripts/messageHeader.js +++ b/chrome/content/scripts/messageHeader.js @@ -126,9 +126,9 @@ RspamdSpamness.Message.displayHeaders = function (update_rules) { converter.charset = "UTF-8"; RspamdSpamness.Message.headerStr = converter.ConvertToUnicode(RspamdSpamness.Message.headerStr); - const [, s] = RspamdSpamness.Message.headerStr.match(/: \S+ \[[-\d.]+ \/ [-\d.]+\] *(.*)$/); - if (s) { - displayScoreRulesHeaders(s); + const m = RspamdSpamness.Message.headerStr.match(/: \S+ \[[-\d.]+ \/ [-\d.]+\] *(.*)$/); + if (m) { + displayScoreRulesHeaders(m[1]); return; } } @@ -149,9 +149,9 @@ RspamdSpamness.Message.displayHeaders = function (update_rules) { // Get symbols from Exim header [RspamdSpamness.Message.headerStr] = getHeaderBody(aMimeMsg.headers, "x-spam-report"); if (RspamdSpamness.Message.headerStr) { - const [, s] = RspamdSpamness.Message.headerStr.match(/^Action: [ a-z]+?(Symbol: .*)Message-ID:/); - if (s) { - displayScoreRulesHeaders(s); + const m = RspamdSpamness.Message.headerStr.match(/^Action: [ a-z]+?(Symbol: .*)Message-ID:/); + if (m) { + displayScoreRulesHeaders(m[1]); return; } }