]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
series: fix obvious breakage for patches with ']' in the name
authorSean Farley <sean@farley.io>
Tue, 11 Jul 2017 18:41:39 +0000 (11:41 -0700)
committerStephen Finucane <stephen@that.guru>
Wed, 12 Jul 2017 09:33:45 +0000 (10:33 +0100)
This copies the same regex that parse uses to find the name. Perhaps future
work should abstract this into a common method.

Signed-off-by: Sean Farley <sean@farley.io>
Signed-off-by: Stephen Finucane <stephen@that.guru>
patchwork/models.py

index e1350c232de15dcca38d74faef92970d6658ab46..56daea166bc4d5d36c0c29c16a9f7f779c670eb3 100644 (file)
@@ -619,7 +619,15 @@ class Series(FilenameMixin, models.Model):
 
     @staticmethod
     def _format_name(obj):
-        return obj.name.split(']')[-1].strip()
+        # The parser ensure 'Submission.name' will always take the form
+        # 'subject' or '[prefix_a,prefix_b,...] subject'. There will never be
+        # multiple prefixes (text inside brackets), thus, we don't need to
+        # account for multiple prefixes here.
+        prefix_re = re.compile(r'^\[([^\]]*)\]\s*(.*)$')
+        match = prefix_re.match(obj.name)
+        if match:
+            return match.group(2)
+        return obj.name.strip()
 
     @property
     def received_total(self):