[sysadmin-bin: 111/168] gnome-post-receive-email: Encode user names as needed



commit 949d0d678e8b0a0da9b678d7a96380051a8d1639
Author: Todd Zullinger <tmz pobox com>
Date:   Wed Jul 22 13:22:10 2009 -0400

    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 = []
 



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