Subject: | Parsing Fixes for fetch_hash |
Date: | Thu, 19 Jun 2014 18:09:37 -0700 |
To: | bug-Mail-IMAPClient [...] rt.cpan.org |
From: | Ken Neighbors <ken [...] kneighbors.com> |
In the process of gathering message information from my gmail account using
the fetch_hash method of Mail::IMAPClient, I ran into a couple problems
with backslashes and unclosed parentheses in the subject line.
Specifically, one of my emails had this "To:" field:
To: "\\"Ken Neighbors\\"" <ken@example.org>
Yes, that has two backslashes before a quote, which showed up in Gmail IMAP
FETCH results as simply "\\" (that is, a quote, two backslashes, and
another quote). This caused a problem in fetch_hash because it thought the
ending-quote was escaped.
Another of my emails had this Subject field showing up in the ENVELOPE
FETCH result:
"Re: Item #270517148775 Instant payment received kenneighbors (ken@example.
.."
That is, it had an opening parenthesis but no closing parentheses. Again,
it caused a problem in fetch_hash.
Background Info:
Mail-IMAPClient-3.35
perl v5.10.1
3.2.0-0.bpo.4-amd64 #1 SMP Debian 3.2.57-3+deb7u2~bpo60+1 x86_64 GNU/Linux
I patched IMAPClient.pm and Parse.grammar to fix these problems and have
attached the patch and several test cases. To summarize the changes:
1. In IMAPClient.pm I updated two regular expressions to recognize an
escaped backslash appearing before an ending quote using the advice from
http://blog.stevenlevithan.com/archives/match-quoted-string
2. In Parse.grammar I allowed an escaped backslash in DOUBLE_QUOTED_STRING
(and SINGLE_QUOTED_STRING, though I'm not sure it is used).
Ken Neighbors
Message body is not shown because sender requested not to inline it.