Skip to contentSkip to conversation

parsemail.py: Improve clean_subject function

PATCH New Jose Lamego 1 participant 1 message Apr 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 parsemail.py: Improve clean_subject function

PATCH prefix is not appropriately identified as such if it is not sepparated from following word in an email Subject line. This leads to wrong patch naming.

This change allows for appropriate patch naming by checking during clean_subject function if "PATCH" prefix in Subject line is not sepparated from following word and adding a space between them.

---
 patchwork/bin/parsemail.py | 6 ++++++
 1 file changed, 6 insertions(+)
patchwork/bin/parsemail.py +6 -0
index 3c3046d..2f5aecb 100755
@@ -633,6 +633,12 @@ def clean_subject(subject, drop_prefixes=None):
     in the subject. If drop_prefixes is provided, remove those too,
     comparing case-insensitively."""
 
+    # Check if PATCH prefix is followed by anoter word without a sepparation
+    # space. Add missing space to allow appropriate parsing
+    if patch_pref.match(subject):
+        index = subject.find(patch_pref.match(subject).group(1))
+        subject = subject[:index + 5] + ' ' + subject[index + 5:]
+
     subject = clean_header(subject)
 
     if drop_prefixes is None:
Signature · 1 line
2.7.4