[PATCH 1/5] gnome-post-receive-email: Encode user names as needed



For user names that are ascii, this changes nothing.  When user names
contain non-ascii, the name will be encoded per RFC 2047.
---
 gnome-post-receive-email |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/gnome-post-receive-email b/gnome-post-receive-email
index d1f7084..577229f 100755
--- a/gnome-post-receive-email
+++ b/gnome-post-receive-email
@@ -33,6 +33,7 @@ import re
 import os
 import pwd
 import sys
+from email import Header
 
 script_path = os.path.realpath(os.path.abspath(sys.argv[0]))
 script_dir = os.path.dirname(script_path)
@@ -850,7 +851,10 @@ def main():
         if m:
             fullname = m.group(1).strip()
             if fullname != "":
-                user_fullname = fullname
+                try:
+                    user_fullname = unicode(fullname, 'ascii')
+                except UnicodeDecodeError:
+                    user_fullname = Header.Header(fullname, 'utf-8').encode()
 
     changes = []
 
-- 
1.6.3.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]