set_payload expects the argument to be already encoded according to the
message's content type and transfer encoding. Force a good charset
and transfer encoding, in case the source message's is incompatible
with the trailers. Otherwise, if the source message specified for
example an iso-8859-1 encoding, we get mojibake in the utf-8 trailers.
Otherwise, adding an 8-bit trailer to a 7-bit message causes the email
module to switch to quoted-printable, without the body actually being
quoted-printable. As a result, all equals sign in the original message
are broken.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
tests/data/0028-tags-need-8bit-encoding.mbox.gz | Bin 0 -> 6585 bytes
tests/test_tags.py | 13 +++++++++++++
www/views.py | 11 ++++++++++-
3 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 tests/data/0028-tags-need-8bit-encoding.mbox.gz
diff --git a/tests/data/0028-tags-need-8bit-encoding.mbox.gz b/tests/data/0028-tags-need-8bit-encoding.mbox.gz
new file mode 100644
index 0000000000000000000000000000000000000000..4156beed26b6e4f2b2f03442ddb01043d411c34f
GIT binary patch
literal 6585
zcmV;q8Aj$GiwFo|0{vS6128Z$I4yKxXLBuXWo2Y7IAUpZEoE+FZ)9n1XD)4GZ+HOQ
zT76UEN|*oJe2T8A+A3U3=+1lMaGyb56a_^<Wt_FFkaS1}@?sJY+}-cKrxQ@{GIM9V
z&r`L#mYSq<y8E18pFVHtRuToM#x>~7U(kd){4g?+AH-3T(d0{PWwuA3g(#VDwRz^z
zF!OCI^P`aO({w(|QWFJB;U)5-!18B;9R<hSfiv}ksteC>pT=%Aw$c=p7!e~dk;8~X
z6uD>;&e_<=p{YL!t&FBf#JWI;E{KvM5Di%=ifIz~Sw<a{($JyFAwp@8#R8kr1@@~?
zG??=aUC<dnj^?3F)AB}w>Xrmw!YEu%$e0YQ#Ll@a#Z`Dik>jWN4UF$m3nmis(HDM_
z&7+r>oO!NKvw0HoJuCA}^!fK^{sTs^DPZlGhz*ZsewwAi28hx-@xSdpKOCa*>OJDz
z!Ly%vXwV(@2FQ01QDjM!RS{#X>7t4SP1ki<5j91{GC4-wC_F-<iY}uCpiOjyHB-VS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Z}ad@>s=rRUWTJfnd-8{Y2Zz*@HxW2D9qB9SY2Lo
zx~sIvo@Ph{54l>SxezLF*KMBGjXsR@1EM(yAL<O)dv(j#up_Q<C$?QcPxrpd@o|B>
zc;=iTy*aCeehzJRF~M^T|KpejV7qf}nF|I)%qj4M2BJpyJ+lm4ha%LqnZ>RxzF7Py
zlCwi7Q@h{z2AjACFKCn}cA2iP?QjzTOu)YY7Z}K*B*OQcT{GOlYzZK}t&jxxam^Bf
zzlPwiR%zKorBW@jzXLd<a}UrSpDLYkk?eGF&TW-hlM;H)9~a#Tu3KZx5(*Fs*wRZd
zdk-^xQp7c&oV$PkGJuGPy7aiPn!fE0;u_yrCas8t@fN7&0i2q`mVF=elw^&|xEq&=
zC*WxBf7PbYQa}IxI|5$zQ~k;YLZ)pqtX~vz=^Ct>v#fprXlyk~+bWDAN{uE0Y_2p!
zg6TpArZR8l0tLN~P+#d}(wi*g-!}S98%f|nSgT$9liu-1&DLmDlv?8YVusFvYou@L
zz6U-%-JwY)uBVO-Ax0vLfAJaZ&?Eoqnu$P%G~NM8zG{ZYH<F{qR~CqW)OmKg&ML5M
z3jXbJw?)o-AIWskoG{3BiGX(Av{}gdWnt|O%bUq*-+2xEX07%20bcnoU0K2&0)O-R
zToV1ruO0i5kGGL=p-i%y#@#MWz7hO~n!QRsEbMOt&ThEd7}o{l`nzA+08?AQ;5pm_
r4^GYASM#tyXJw{y#EoIEe{KMnMcDD<SN|*~{hs#Up%DCPMmqoih852Z
literal 0
HcmV?d00001
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 6c162de..a49a660 100755
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -12,6 +12,8 @@ import sys
import os
sys.path.append(os.path.dirname(__file__))
from tests.patchewtest import PatchewTestCase, main
+import email
+from mbox import decode_payload
class ImportTest(PatchewTestCase):
@@ -48,5 +50,16 @@ class ImportTest(PatchewTestCase):
message = self.api_client.get(uri)
self.assertEquals(message.data['tags'], [])
+ def test_mbox_with_8bit_tags(self):
+ self.cli_login()
+ self.cli_import("0028-tags-need-8bit-encoding.mbox.gz")
+ self.cli_logout()
+ mbox = self.client.get('/QEMU/20181126152836.25379-1-rkagan@virtuozzo.com/mbox')
+ parser = email.parser.BytesParser(policy=email.policy.SMTP)
+ msg = parser.parsebytes(mbox.content)
+ payload = decode_payload(msg)
+ self.assertIn('SynICState *synic = get_synic(cs);', payload)
+ self.assertIn('Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>', payload)
+
if __name__ == '__main__':
main()
diff --git a/www/views.py b/www/views.py
index 45f63c8..2aae127 100644
--- a/www/views.py
+++ b/www/views.py
@@ -17,6 +17,7 @@ from django.utils.html import format_html
from django.conf import settings
import api
import email
+import quopri
from mbox import decode_payload
import re
from mod import dispatch_module_hook
@@ -292,7 +293,15 @@ def view_mbox(request, project, message_id):
return msg.as_bytes(unixfrom=True)
payload = decode_payload(container)
- container.set_payload('\n'.join(mbox_with_tags_iter(payload, m.tags)))
+ # We might be adding 8-bit trailers to a message with 7bit CTE. For
+ # patches, quoted-printable is safe and mostly human-readable.
+ try:
+ container.replace_header('Content-Transfer-Encoding', 'quoted-printable')
+ except:
+ msg.add_header('Content-Transfer-Encoding', 'quoted-printable')
+ payload = '\n'.join(mbox_with_tags_iter(payload, m.tags))
+ payload = quopri.encodestring(payload.encode('utf-8'))
+ container.set_payload(payload, charset='utf-8')
return msg.as_bytes(unixfrom=True)
s = api.models.Message.objects.find_message(message_id, project)
--
2.19.1
_______________________________________________
Patchew-devel mailing list
Patchew-devel@redhat.com
https://www.redhat.com/mailman/listinfo/patchew-devel
On Tue, Nov 27, 2018 at 09:49:35AM +0100, Paolo Bonzini wrote: > set_payload expects the argument to be already encoded according to the > message's content type and transfer encoding. Force a good charset > and transfer encoding, in case the source message's is incompatible > with the trailers. Otherwise, if the source message specified for > example an iso-8859-1 encoding, we get mojibake in the utf-8 trailers. > > Otherwise, adding an 8-bit trailer to a 7-bit message causes the email > module to switch to quoted-printable, without the body actually being > quoted-printable. As a result, all equals sign in the original message > are broken. > > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Caio Carrara <ccarrara@redhat.com> > --- > tests/data/0028-tags-need-8bit-encoding.mbox.gz | Bin 0 -> 6585 bytes > tests/test_tags.py | 13 +++++++++++++ > www/views.py | 11 ++++++++++- > 3 files changed, 23 insertions(+), 1 deletion(-) > create mode 100644 tests/data/0028-tags-need-8bit-encoding.mbox.gz > > diff --git a/tests/data/0028-tags-need-8bit-encoding.mbox.gz b/tests/data/0028-tags-need-8bit-encoding.mbox.gz > new file mode 100644 > index 0000000000000000000000000000000000000000..4156beed26b6e4f2b2f03442ddb01043d411c34f > GIT binary patch > literal 6585 > zcmV;q8Aj$GiwFo|0{vS6128Z$I4yKxXLBuXWo2Y7IAUpZEoE+FZ)9n1XD)4GZ+HOQ > zT76UEN|*oJe2T8A+A3U3=+1lMaGyb56a_^<Wt_FFkaS1}@?sJY+}-cKrxQ@{GIM9V > z&r`L#mYSq<y8E18pFVHtRuToM#x>~7U(kd){4g?+AH-3T(d0{PWwuA3g(#VDwRz^z > zF!OCI^P`aO({w(|QWFJB;U)5-!18B;9R<hSfiv}ksteC>pT=%Aw$c=p7!e~dk;8~X > z6uD>;&e_<=p{YL!t&FBf#JWI;E{KvM5Di%=ifIz~Sw<a{($JyFAwp@8#R8kr1@@~? > zG??=aUC<dnj^?3F)AB}w>Xrmw!YEu%$e0YQ#Ll@a#Z`Dik>jWN4UF$m3nmis(HDM_ > z&7+r>oO!NKvw0HoJuCA}^!fK^{sTs^DPZlGhz*ZsewwAi28hx-@xSdpKOCa*>OJDz > z!Ly%vXwV(@2FQ01QDjM!RS{#X>7t4SP1ki<5j91{GC4-wC_F-<iY}uCpiOjyHB-VS > z#)!u{{4eze!^1zZ8QIp%i_#30zL_R@FeObiBmim_Rd+-<<PLzvU8!>ZC|fjCYA*c% > z$%00JutY<EE{Z9i&+!pBVH76vq~DIe@*uHpeCM&u9k@}lSB>|GPp~N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<C$?QcPxrpd@o|B> > zc;=iTy*aCeehzJRF~M^T|KpejV7qf}nF|I)%qj4M2BJpyJ+lm4ha%LqnZ>RxzF7Py > zlCwi7Q@h{z2AjACFKCn}cA2iP?QjzTOu)YY7Z}K*B*OQcT{GOlYzZK}t&jxxam^Bf > zzlPwiR%zKorBW@jzXLd<a}UrSpDLYkk?eGF&TW-hlM;H)9~a#Tu3KZx5(*Fs*wRZd > zdk-^xQp7c&oV$PkGJuGPy7aiPn!fE0;u_yrCas8t@fN7&0i2q`mVF=elw^&|xEq&= > zC*WxBf7PbYQa}IxI|5$zQ~k;YLZ)pqtX~vz=^Ct>v#fprXlyk~+bWDAN{uE0Y_2p! > zg6TpArZR8l0tLN~P+#d}(wi*g-!}S98%f|nSgT$9liu-1&DLmDlv?8YVusFvYou@L > zz6U-%-JwY)uBVO-Ax0vLfAJaZ&?Eoqnu$P%G~NM8zG{ZYH<F{qR~CqW)OmKg&ML5M > z3jXbJw?)o-AIWskoG{3BiGX(Av{}gdWnt|O%bUq*-+2xEX07%20bcnoU0K2&0)O-R > zToV1ruO0i5kGGL=p-i%y#@#MWz7hO~n!QRsEbMOt&ThEd7}o{l`nzA+08?AQ;5pm_ > r4^GYASM#tyXJw{y#EoIEe{KMnMcDD<SN|*~{hs#Up%DCPMmqoih852Z > > literal 0 > HcmV?d00001 > > diff --git a/tests/test_tags.py b/tests/test_tags.py > index 6c162de..a49a660 100755 > --- a/tests/test_tags.py > +++ b/tests/test_tags.py > @@ -12,6 +12,8 @@ import sys > import os > sys.path.append(os.path.dirname(__file__)) > from tests.patchewtest import PatchewTestCase, main > +import email > +from mbox import decode_payload > > class ImportTest(PatchewTestCase): > > @@ -48,5 +50,16 @@ class ImportTest(PatchewTestCase): > message = self.api_client.get(uri) > self.assertEquals(message.data['tags'], []) > > + def test_mbox_with_8bit_tags(self): > + self.cli_login() > + self.cli_import("0028-tags-need-8bit-encoding.mbox.gz") > + self.cli_logout() > + mbox = self.client.get('/QEMU/20181126152836.25379-1-rkagan@virtuozzo.com/mbox') > + parser = email.parser.BytesParser(policy=email.policy.SMTP) > + msg = parser.parsebytes(mbox.content) > + payload = decode_payload(msg) > + self.assertIn('SynICState *synic = get_synic(cs);', payload) > + self.assertIn('Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>', payload) > + > if __name__ == '__main__': > main() > diff --git a/www/views.py b/www/views.py > index 45f63c8..2aae127 100644 > --- a/www/views.py > +++ b/www/views.py > @@ -17,6 +17,7 @@ from django.utils.html import format_html > from django.conf import settings > import api > import email > +import quopri > from mbox import decode_payload > import re > from mod import dispatch_module_hook > @@ -292,7 +293,15 @@ def view_mbox(request, project, message_id): > return msg.as_bytes(unixfrom=True) > > payload = decode_payload(container) > - container.set_payload('\n'.join(mbox_with_tags_iter(payload, m.tags))) > + # We might be adding 8-bit trailers to a message with 7bit CTE. For > + # patches, quoted-printable is safe and mostly human-readable. > + try: > + container.replace_header('Content-Transfer-Encoding', 'quoted-printable') > + except: > + msg.add_header('Content-Transfer-Encoding', 'quoted-printable') > + payload = '\n'.join(mbox_with_tags_iter(payload, m.tags)) > + payload = quopri.encodestring(payload.encode('utf-8')) > + container.set_payload(payload, charset='utf-8') > return msg.as_bytes(unixfrom=True) > > s = api.models.Message.objects.find_message(message_id, project) > -- > 2.19.1 > > _______________________________________________ > Patchew-devel mailing list > Patchew-devel@redhat.com > https://www.redhat.com/mailman/listinfo/patchew-devel -- Caio Carrara Software Engineer, Virt Team - Red Hat ccarrara@redhat.com _______________________________________________ Patchew-devel mailing list Patchew-devel@redhat.com https://www.redhat.com/mailman/listinfo/patchew-devel
© 2016 - 2024 Red Hat, Inc.