]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
models: Handle unset 'Submission.content'
authorStephen Finucane <stephen@that.guru>
Sun, 7 Jul 2019 16:10:42 +0000 (17:10 +0100)
committerStephen Finucane <stephen@that.guru>
Mon, 2 Mar 2020 17:07:21 +0000 (17:07 +0000)
It's unlikely but 'Submission.content' is nullable and we weren't
handling this here. Fix that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 7f6685a2a ("Fix CRLF newlines upon submission changes")
patchwork/models.py

index be71d40778921f384ecbbd0581d33f62a3a18ca9..08ee341eb6c12426c95eae6f100635aff2ad65d5 100644 (file)
@@ -347,7 +347,9 @@ class EmailMixin(models.Model):
         # message content to '\r\n'. We need to fix them to avoid problems,
         # especially as git complains about malformed patches when PW runs
         # on PY2
-        self.content = self.content.replace('\r\n', '\n')
+        if self.content:
+            self.content = self.content.replace('\r\n', '\n')
+
         super(EmailMixin, self).save(*args, **kwargs)
 
     class Meta: