areguera / rpms / mailman

Forked from rpms/mailman 4 years ago
Clone

Blame SOURCES/mailman-2.1.9-unicode.patch

7812c9
diff -ruN mailman-2.1.12-a/Mailman/Archiver/pipermail.py mailman-2.1.12-b/Mailman/Archiver/pipermail.py
7812c9
--- mailman-2.1.12-a/Mailman/Archiver/pipermail.py	2009-02-23 22:23:35.000000000 +0100
7812c9
+++ mailman-2.1.12-b/Mailman/Archiver/pipermail.py	2009-07-28 12:19:53.000000000 +0200
7812c9
@@ -45,24 +45,27 @@
7812c9
 
7812c9
 def fixAuthor(author):
7812c9
     "Canonicalize a name into Last, First format"
7812c9
-    # If there's a comma, guess that it's already in "Last, First" format
7812c9
-    if ',' in author:
7812c9
+    try:
7812c9
+        # If there's a comma, guess that it's already in "Last, First" format
7812c9
+        if ',' in author:
7812c9
+            return author
7812c9
+        L = author.split()
7812c9
+        i = len(L) - 1
7812c9
+        if i == 0:
7812c9
+            return author # The string's one word--forget it
7812c9
+        if author.upper() == author or author.lower() == author:
7812c9
+            # Damn, the name is all upper- or lower-case.
7812c9
+            while i > 0 and L[i-1].lower() in smallNameParts:
7812c9
+                i = i - 1
7812c9
+        else:
7812c9
+            # Mixed case; assume that small parts of the last name will be
7812c9
+            # in lowercase, and check them against the list.
7812c9
+            while i>0 and (L[i-1][0] in lowercase or
7812c9
+                           L[i-1].lower() in smallNameParts):
7812c9
+                i = i - 1
7812c9
+        author = SPACE.join(L[-1:] + L[i:-1]) + ', ' + SPACE.join(L[:i])
7812c9
+    except UnicodeDecodeError:
7812c9
         return author
7812c9
-    L = author.split()
7812c9
-    i = len(L) - 1
7812c9
-    if i == 0:
7812c9
-        return author # The string's one word--forget it
7812c9
-    if author.upper() == author or author.lower() == author:
7812c9
-        # Damn, the name is all upper- or lower-case.
7812c9
-        while i > 0 and L[i-1].lower() in smallNameParts:
7812c9
-            i = i - 1
7812c9
-    else:
7812c9
-        # Mixed case; assume that small parts of the last name will be
7812c9
-        # in lowercase, and check them against the list.
7812c9
-        while i>0 and (L[i-1][0] in lowercase or
7812c9
-                       L[i-1].lower() in smallNameParts):
7812c9
-            i = i - 1
7812c9
-    author = SPACE.join(L[-1:] + L[i:-1]) + ', ' + SPACE.join(L[:i])
7812c9
     return author
7812c9
 
7812c9
 # Abstract class for databases