From: Sean Farley Date: Tue, 11 Jul 2017 18:41:39 +0000 (-0700) Subject: series: fix obvious breakage for patches with ']' in the name X-Git-Tag: v2.0.0~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c4ad0d8842482f3dc6b65f47f0cef8188a33aeac;p=thirdparty%2Fpatchwork.git series: fix obvious breakage for patches with ']' in the name 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 Signed-off-by: Stephen Finucane --- diff --git a/patchwork/models.py b/patchwork/models.py index e1350c23..56daea16 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -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):