[PATCH 1/4] tags: be a bit more permissive in what we render to a message

Daniel Axtens dja at axtens.net
Sat Feb 3 14:55:49 AEDT 2018


Series pushed to master.
Patches 1 and 2 pushed to stable/2.0.

Regards,
Daniel

Daniel Axtens <dja at axtens.net> writes:

> Currently we render a tag from a comment into a message if it is
>
>  '^(whatever)-by: .*'
>
> We found a patch that had a UTF-8 non-breaking space after the colon,
> and this was breaking the regex. So just remove the requirement for
> a space entirely.
>
> Closes: #124
> Signed-off-by: Daniel Axtens <dja at axtens.net>
> ---
>  patchwork/models.py               |  2 +-
>  patchwork/tests/test_mboxviews.py | 28 ++++++++++++++++++++--------
>  2 files changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/patchwork/models.py b/patchwork/models.py
> index 11886f1a73a5..3bf7c72dbe08 100644
> --- a/patchwork/models.py
> +++ b/patchwork/models.py
> @@ -317,7 +317,7 @@ class EmailMixin(models.Model):
>      content = models.TextField(null=True, blank=True)
>  
>      response_re = re.compile(
> -        r'^(Tested|Reviewed|Acked|Signed-off|Nacked|Reported)-by: .*$',
> +        r'^(Tested|Reviewed|Acked|Signed-off|Nacked|Reported)-by:.*$',
>          re.M | re.I)
>  
>      @property
> diff --git a/patchwork/tests/test_mboxviews.py b/patchwork/tests/test_mboxviews.py
> index 0dc4abbeb715..2d6cdc303023 100644
> --- a/patchwork/tests/test_mboxviews.py
> +++ b/patchwork/tests/test_mboxviews.py
> @@ -39,21 +39,33 @@ class MboxPatchResponseTest(TestCase):
>      """Test that the mbox view appends the Acked-by from a patch comment."""
>  
>      def setUp(self):
> -        project = create_project()
> +        self.project = create_project()
>          self.person = create_person()
> -        self.patch = create_patch(
> -            project=project,
> +
> +    def test_patch_response(self):
> +        patch = create_patch(
> +            project=self.project,
>              submitter=self.person,
>              content='comment 1 text\nAcked-by: 1\n')
> -        self.comment = create_comment(
> -            submission=self.patch,
> +        create_comment(
> +            submission=patch,
>              submitter=self.person,
>              content='comment 2 text\nAcked-by: 2\n')
> -
> -    def test_patch_response(self):
> -        response = self.client.get(reverse('patch-mbox', args=[self.patch.id]))
> +        response = self.client.get(reverse('patch-mbox', args=[patch.id]))
>          self.assertContains(response, 'Acked-by: 1\nAcked-by: 2\n')
>  
> +    def test_patch_utf8_nbsp(self):
> +        patch = create_patch(
> +            project=self.project,
> +            submitter=self.person,
> +            content='patch text\n')
> +        create_comment(
> +            submission=patch,
> +            submitter=self.person,
> +            content=u'comment\nAcked-by:\u00A0 foo')
> +        response = self.client.get(reverse('patch-mbox', args=[patch.id]))
> +        self.assertContains(response, u'\u00A0 foo\n')
> +
>  
>  class MboxPatchSplitResponseTest(TestCase):
>  
> -- 
> 2.14.1


More information about the Patchwork mailing list