public inbox for [email protected]
 help / color / mirror / Atom feed
From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: GNU/Weeb Mailing List <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	Nugra <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	Arthur Lapz <[email protected]>
Subject: [PATCH pit] bin/public-inbox-tg: Fix fatal error when "To:" or CC list is empty
Date: Sat, 26 Feb 2022 19:27:50 +0000	[thread overview]
Message-ID: <[email protected]> (raw)

When "To:" or CC list is empty, we don't have the $toList or $ccList
variable, we must always check their existence before entering the
array_merge() call. Fix it by using null coalescing operator and
fallback to an empty array.

Link: https://t.me/GNUWeeb/544137
Reported-by: Arthur Lapz <[email protected]>
Fixes: b7a968b53f42f7392ac2fb3450524bb4a949baab ("bin/public-inbox-tg: Add Telegram CC notification support")
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---
 bin/public-inbox-tg.php | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bin/public-inbox-tg.php b/bin/public-inbox-tg.php
index 61d4968..f17fffe 100644
--- a/bin/public-inbox-tg.php
+++ b/bin/public-inbox-tg.php
@@ -157,7 +157,10 @@ function fx(string $input): int
 	if ($ccListStr)
 		$msg .= "{$ccListStr}\n";
 
-	$tgCCs = array_merge(...[listTelegramLookup($toList), listTelegramLookup($ccList)]);
+	$tgCCs = array_merge(...[
+		listTelegramLookup($toList ?? []),
+		listTelegramLookup($ccList ?? [])
+	]);
 	$tgCCs = array_unique($tgCCs);
 
 	if (count($tgCCs) > 0)

base-commit: 48fc9b434d878691d11c77beab3fa459a337ce48
-- 
2.32.0


             reply	other threads:[~2022-02-26 19:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-26 19:27 Alviro Iskandar Setiawan [this message]
2022-02-26 19:40 ` [PATCH pit] bin/public-inbox-tg: Fix fatal error when "To:" or CC list is empty Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220226192750.2563520-1-alviro.iskandar@gnuweeb.org \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox