Patchwork D3952: patchbomb: ensure all headers and values given to email mod are native strings

login
register
mail settings
Submitter phabricator
Date Aug. 1, 2018, 5:18 p.m.
Message ID <efa4943d41aeb8fae787a61209bc4f59@localhost.localdomain>
Download mbox | patch
Permalink /patch/33027/
State Not Applicable
Headers show

Comments

phabricator - Aug. 1, 2018, 5:18 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG65ed2fcb9032: patchbomb: ensure all headers and values given to email mod are native strings (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3952?vs=9608&id=9714

REVISION DETAIL
  https://phab.mercurial-scm.org/D3952

AFFECTED FILES
  hgext/patchbomb.py

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -780,6 +780,16 @@ 
             m['Bcc'] = ', '.join(bcc)
         if replyto:
             m['Reply-To'] = ', '.join(replyto)
+        # Fix up all headers to be native strings.
+        # TODO(durin42): this should probably be cleaned up above in the future.
+        if pycompat.ispy3:
+            for hdr, val in list(m.items()):
+                if isinstance(hdr, bytes):
+                    del m[hdr]
+                    hdr = pycompat.strurl(hdr)
+                if isinstance(val, bytes):
+                    val = pycompat.strurl(val)
+                m[hdr] = val
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.pager('email')