From mboxrd@z Thu Jan 1 00:00:00 1970 From: Arun Isaac To: Ricardo Wurmus Cc: guile-email@systemreboot.net Subject: Re: [guile-email] parse-email-headers returns just =?utf-8?B?4oCc?= =?utf-8?B?ZmllbGRz4oCd?= In-Reply-To: <874ktal0zb.fsf@elephly.net> References: <87k129kowf.fsf@elephly.net> <875zdqlnfs.fsf@elephly.net> <874ktal0zb.fsf@elephly.net> Date: Fri, 24 Apr 2020 03:24:36 +0530 Message-ID: MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" List-Id: Message-ID: <20200423215436.rNr6ZqEWEK2Ew4x-EfZN2SPz_TQLJSrTwrF2K-J5biY@z> --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > 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=E2=80=99ll 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. =2D-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)))))) =2D-8<---------------cut here---------------end--------------->8--- --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEf3MDQ/Lwnzx3v3nTLiXui2GAK7MFAl6iDqcACgkQLiXui2GA K7O/rgf/Xin+Tkuuhw6Vh5zIKc4zVFctJ/UKBnhoT0DJnq1WuhcbziAiEMD2OSlJ 9mMiBmG7uH3x02dDSVz1N9Nn1OlbBDtpj1jATWQJdG2SrrVxzctYcQFBdwxoygcl rgquWorH8MJHaFNhLIlK90aYju7oje3iKEY7qIZTQSCWA8wqS5Qjkq46GzQO+52q zUiXKTr1gkcaHqWsVL6ZJCpnURU649slDlOsGeD+J4WPudmwvan8d/l+BfwfYTx0 TVWzC0DCgu6OK5MCvWZxvMtzKoG1G2idvKvoW7zBYTEnhxBjHIGZsz+22RSUwi1t VhY1h1Ti1vDfje82RPJdJh5POaP/+g== =qOMT -----END PGP SIGNATURE----- --=-=-=--