areguera / rpms / mailman

Forked from rpms/mailman 5 years ago
Clone

Blame SOURCES/mailman-2.1.9-unicode.patch

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