[Patchew-devel] [PATCH] fix parsing of RFC2047 headers

Paolo Bonzini posted 1 patch 1 month, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/patchew-ci tags/patchew/20210816181939.7142-1-pbonzini@redhat.com
mbox.py                              |   3 ++-
tests/data/0035-rfc2047-from.mbox.gz | Bin 0 -> 8188 bytes
tests/test_mbox.py                   |   6 ++++++
3 files changed, 8 insertions(+), 1 deletion(-)
create mode 100644 tests/data/0035-rfc2047-from.mbox.gz

[Patchew-devel] [PATCH] fix parsing of RFC2047 headers

Posted by Paolo Bonzini 1 month, 1 week ago
Quoting <https://tools.ietf.org/html/rfc2047#section-6.2>:

> NOTE: Decoding and display of encoded-words occurs *after* a
> structured field body is parsed into tokens.  It is therefore
> possible to hide special characters in encoded-words which, when
> displayed, will be indistinguishable from special characters in the
> surrounding text.  For this and other reasons, it is NOT generally
> possible to translate a message header containing encoded-words to
> an unencoded form which can be parsed by an RFC 822 mail reader.

So do not use decode_header() on the whole From header, instead
parse the header first, then decode the name which could be
RFC2047 encoded.

Reported-by: John Snow <jsnow@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 mbox.py                              |   3 ++-
 tests/data/0035-rfc2047-from.mbox.gz | Bin 0 -> 8188 bytes
 tests/test_mbox.py                   |   6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 tests/data/0035-rfc2047-from.mbox.gz

diff --git a/mbox.py b/mbox.py
index be10166..20abca1 100644
--- a/mbox.py
+++ b/mbox.py
@@ -28,7 +28,8 @@ def _parse_header(header):
 
 
 def parse_address(addr_str):
-    name, addr = email.utils.parseaddr(_parse_header(addr_str))
+    name, addr = email.utils.parseaddr(addr_str)
+    name = _parse_header(name)
     return name, addr
 
 
diff --git a/tests/data/0035-rfc2047-from.mbox.gz b/tests/data/0035-rfc2047-from.mbox.gz
new file mode 100644
index 0000000000000000000000000000000000000000..1e59ea710ee9cf10c199c8b45ada078a103052fd
GIT binary patch
literal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ygc$HHNW?L`riyrR74N)
zi;WOB1@3Nd@k1MNS$c4K$u`ho5b_socdlGtJ%PzTU>!Zr7++er`rdcGogJNDnLcg(
zjV|r;;8p379@>r6zj#~v3D(d@g*l8h^ig3BV-0<Kk?++u3um+rWwknqp5o{!hF$|9
z^iey!Foe(t?eO|81>O1JQ#0_~`L*?b-m=Gc)t!(36<ZTum;-+{bCl>|Y-ex!?Y3IL
it(<ZGJAa)V|F;^qw?Fj%0~87fq5lI>Z{4Z_WB>qomDp$i

literal 0
HcmV?d00001

diff --git a/tests/test_mbox.py b/tests/test_mbox.py
index 8a86d11..4312a2e 100755
--- a/tests/test_mbox.py
+++ b/tests/test_mbox.py
@@ -62,6 +62,12 @@ Virtualization:  qemu.org | libvirt.org
             msg = mbox.MboxMessage(f.read())
         self.assertTrue(msg.is_patch())
 
+    def test_rfc2047_from(self):
+        dp = self.get_data_path("0035-rfc2047-from.mbox.gz")
+        with open(dp, "r") as f:
+            msg = mbox.MboxMessage(f.read())
+        self.assertTrue(msg.get_from()[1] == 'AIERPATIJIANG1@kingsoft.com')
+
     def test_get_json(self):
         dp = self.get_data_path("0001-simple-patch.mbox.gz")
         with open(dp, "r") as f:
-- 
2.31.1

_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel

Re: [Patchew-devel] [PATCH] fix parsing of RFC2047 headers

Posted by John Snow 1 month, 1 week ago
On Mon, Aug 16, 2021 at 2:19 PM Paolo Bonzini <pbonzini@redhat.com> wrote:

> Quoting <https://tools.ietf.org/html/rfc2047#section-6.2>:
>
> > NOTE: Decoding and display of encoded-words occurs *after* a
> > structured field body is parsed into tokens.  It is therefore
> > possible to hide special characters in encoded-words which, when
> > displayed, will be indistinguishable from special characters in the
> > surrounding text.  For this and other reasons, it is NOT generally
> > possible to translate a message header containing encoded-words to
> > an unencoded form which can be parsed by an RFC 822 mail reader.
>
> So do not use decode_header() on the whole From header, instead
> parse the header first, then decode the name which could be
> RFC2047 encoded.
>
> Reported-by: John Snow <jsnow@redhat.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>

Thanks Paolo -- LGTM. Thanks for the quick diagnosis.

--js
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/patchew-devel