From: Alviro Iskandar Setiawan <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Alviro Iskandar Setiawan <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Faris Suryanto <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: Re: test debug
Date: Sun, 6 Mar 2022 13:00:24 +0000 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAOG64qPb3Gep8aXvGY0hoisE--ZO5hMQaQPkLhvxRFWP-r1rqg@mail.gmail.com>
Subject: [PATCH pit v1] bin/public-inbox-tg: Fix regex pattern for headers
From: Alviro Iskandar Setiawan <[email protected]>
When testing email with Faris, we found that Faris' emails don't get
processed. They appear on the lore, but don't appear on Telegram. Sir
Ammar debugged this bug and the log said: "Cannot get the \"message-id\"
line".
It turned out that the regex pattern for headers was wrong, if the
header to be matched happens to be at the end of the headers, it will
not have a double LF because previously we have already split the
double LF with explode(). Fix this by changing the pattern to match the
header if it happens to be at the end of the headers.
Cc: Faris Suryanto <[email protected]>
Debugged-by: Ammar Faizi <[email protected]>
Signed-off-by: Alviro Iskandar Setiawan <[email protected]>
---
bin/public-inbox-tg.php | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/bin/public-inbox-tg.php b/bin/public-inbox-tg.php
index 9d5771f..2e611ec 100644
--- a/bin/public-inbox-tg.php
+++ b/bin/public-inbox-tg.php
@@ -145,27 +145,27 @@ function fx(string $input): int
}
$body = trim($hdr[1]);
- $hdr = $hdr[0];
+ $hdr = trim($hdr[0]);
- if (!preg_match("/(?:^|\\n)subject:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (!preg_match("/(?:^|\\n)subject:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$err = "Cannot get the \"subject\" line";
goto out;
}
$subject = clean_header_val($m[1]);
- if (!preg_match("/(?:^|\\n)from:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (!preg_match("/(?:^|\\n)from:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$err = "Cannot get the \"from\" line";
goto out;
}
$from = clean_header_val($m[1]);
- if (!preg_match("/(?:^|\\n)date:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (!preg_match("/(?:^|\\n)date:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$err = "Cannot get the \"date\" line";
goto out;
}
$date = clean_header_val($m[1]);
- if (!preg_match("/(?:^|\\n)message-id:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (!preg_match("/(?:^|\\n)message-id:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$err = "Cannot get the \"message-id\" line";
goto out;
}
@@ -173,7 +173,7 @@ function fx(string $input): int
if ($msgId[0] === '<' && $msgId[strlen($msgId) - 1] === '>')
$msgId = substr(clean_header_val($msgId), 1, -1);
- if (preg_match("/(?:^|\\n)in-reply-to:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (preg_match("/(?:^|\\n)in-reply-to:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$inReplyTo = $m[1];
if ($inReplyTo[0] === '<' && $inReplyTo[strlen($inReplyTo) - 1] === '>')
$inReplyTo = substr(clean_header_val($inReplyTo), 1, -1);
@@ -182,7 +182,7 @@ function fx(string $input): int
}
$err = "";
- if (preg_match("/(?:^|\\n)to:\s+?(.+?)(?:\\n\S+\:|\\n\\n)/si", $hdr, $m)) {
+ if (preg_match("/(?:^|\\n)to:\s+?(.+?)(?:\\n\S+\:|$)/si", $hdr, $m)) {
$toList = extractList(clean_header_val($m[1]));
$toListStr = buildList($toList, "To");
} else {
base-commit: 667913decf1869fde55d8fd17d66b4a294670617
--
2.32.0
next prev parent reply other threads:[~2022-03-06 13:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-06 10:49 test debug Alviro Iskandar Setiawan
2022-03-06 10:53 ` Ammar Faizi
2022-03-06 11:01 ` Ammar Faizi
2022-03-06 11:03 ` Alviro Iskandar Setiawan
2022-03-06 11:04 ` Ammar Faizi
2022-03-06 11:08 ` Alviro Iskandar Setiawan
2022-03-06 11:12 ` Ammar Faizi
2022-03-06 11:15 ` Alviro Iskandar Setiawan
2022-03-06 13:00 ` Alviro Iskandar Setiawan [this message]
2022-03-06 13:06 ` Ammar Faizi
2022-03-06 13:10 ` Alviro Iskandar Setiawan
2022-03-06 13:13 ` Faris Suryanto
2022-03-06 13:14 ` Alviro Iskandar Setiawan
2022-03-06 13:17 ` Alviro Iskandar Setiawan
2022-03-06 13:20 ` Ammar Faizi
2022-03-06 13:25 ` Alviro Iskandar Setiawan
2022-03-06 13:33 ` 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=20220306130024.520329-1-alviro.iskandar@gnuweeb.org \
[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