guile-email discussion
 help / color / Atom feed
WARNING: multiple messages have this Message-ID
From: Arun Isaac <arunisaac@systemreboot.net>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guile-email@systemreboot.net
Subject: Re: [guile-email] parse-email-headers returns just “fields”
Date: Fri, 24 Apr 2020 03:24:36 +0530
Message-ID: <cu7d07xx3z7.fsf@systemreboot.net> (raw)
In-Reply-To: <874ktal0zb.fsf@elephly.net>

[-- Attachment #1.1: Type: text/plain, Size: 1668 bytes --]


> Yeah, I figured as much, but I shied away from reading the file in
> bytevector chunks that would then need to be searched for control
> characters to split the parts of the log file.  I’ll probably do that
> later, but for the first pass I just decided to use read-line.

I understand. Binary read is a little painful. Perhaps you could use the
read-bytes-till function in email/utils.scm of guile-email. It is kinda
internal to guile-email. So, if you're using it, you should probably
copy it into your source tree.

> The mbox begins at the first ^G and ends at the next ^C.

Ah, I see the problem. This is actually a bug on debbugs' part. The
mbox/email starting at line 194 is invalid. It is neither a valid email
nor a valid mbox. For it to be a valid mbox, the "From ..." line
(currently at line 195) should be the first line. It should not occur in
between the email headers as it does now. For it to be a valid email,
the "From ..." line should not occur at all.

I guess the only workaround is to find and delete the "From ..."
line. Here's one possible way to do it.

--8<---------------cut here---------------start------------->8---
(use-modules (email utils))

(parse-email
 (call-with-input-file "/path/to/40755.log"
   (lambda (port)
     (read-bytes-till port (make-bytevector 1 #x07))
     (get-line port)
     (get-line port)
     (let ((possible-from-line (get-line port)))
       (unless (string-prefix? "From " possible-from-line)
         (unget-string port possible-from-line))
       (read-bytes-till port (make-bytevector 1 #x03))))))
--8<---------------cut here---------------end--------------->8---

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

[-- Attachment #2: Type: text/plain, Size: 110 bytes --]

-- 
guile-email mailing list
guile-email@systemreboot.net
https://lists.systemreboot.net/listinfo/guile-email

From: Arun Isaac <arunisaac@systemreboot.net>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guile-email@systemreboot.net
Subject: Re: [guile-email] parse-email-headers returns just “fields”
Date: Fri, 24 Apr 2020 03:24:36 +0530
Message-ID: <cu7d07xx3z7.fsf@systemreboot.net> (raw)
Message-ID: <20200423215436.rNr6ZqEWEK2Ew4x-EfZN2SPz_TQLJSrTwrF2K-J5biY@z> (raw)
In-Reply-To: <874ktal0zb.fsf@elephly.net>


[-- Attachment #1: Type: text/plain, Size: 1668 bytes --]


> Yeah, I figured as much, but I shied away from reading the file in
> bytevector chunks that would then need to be searched for control
> characters to split the parts of the log file.  I’ll probably do that
> later, but for the first pass I just decided to use read-line.

I understand. Binary read is a little painful. Perhaps you could use the
read-bytes-till function in email/utils.scm of guile-email. It is kinda
internal to guile-email. So, if you're using it, you should probably
copy it into your source tree.

> The mbox begins at the first ^G and ends at the next ^C.

Ah, I see the problem. This is actually a bug on debbugs' part. The
mbox/email starting at line 194 is invalid. It is neither a valid email
nor a valid mbox. For it to be a valid mbox, the "From ..." line
(currently at line 195) should be the first line. It should not occur in
between the email headers as it does now. For it to be a valid email,
the "From ..." line should not occur at all.

I guess the only workaround is to find and delete the "From ..."
line. Here's one possible way to do it.

--8<---------------cut here---------------start------------->8---
(use-modules (email utils))

(parse-email
 (call-with-input-file "/path/to/40755.log"
   (lambda (port)
     (read-bytes-till port (make-bytevector 1 #x07))
     (get-line port)
     (get-line port)
     (let ((possible-from-line (get-line port)))
       (unless (string-prefix? "From " possible-from-line)
         (unget-string port possible-from-line))
       (read-bytes-till port (make-bytevector 1 #x03))))))
--8<---------------cut here---------------end--------------->8---

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 12:24 Ricardo Wurmus
2020-04-23  1:26 ` Arun Isaac
2020-04-23  1:26   ` Arun Isaac
2020-04-23  6:35   ` Ricardo Wurmus
2020-04-23 11:31     ` Arun Isaac
2020-04-23 11:31       ` Arun Isaac
2020-04-23 14:40       ` Ricardo Wurmus
2020-04-23 21:54         ` Arun Isaac [this message]
2020-04-23 21:54           ` Arun Isaac

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=cu7d07xx3z7.fsf@systemreboot.net \
    --to=arunisaac@systemreboot.net \
    --cc=guile-email@systemreboot.net \
    --cc=rekado@elephly.net \
    /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

guile-email discussion

Archives are clonable:
	git clone --mirror http://lists.systemreboot.net/guile-email/0 guile-email/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-email guile-email/ http://lists.systemreboot.net/guile-email \
		guile-email@systemreboot.net
	public-inbox-index guile-email

Example config snippet for mirrors


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git