Message ID | 20180206122709.14114-1-vkabatov@redhat.com |
---|---|
State | Superseded |
Headers | show |
Series | Fix CRLF newlines upon submission changes | expand |
Context | Check | Description |
---|---|---|
dja/snowpatch-0_1_0 | success | master/apply_patch Successfully applied |
dja/snowpatch-snowpatch_job_snowpatch-patchwork | success | Test snowpatch/job/snowpatch-patchwork on branch master |
Hi Veronika, > After changing submission via admin interface, CRLF newlines are > suddenly present in the body. Replace them back to '\n'. > > The issue was found after modifying submission via admin interface > using Python 2 and downloading the respective mbox file (git choked on > downloaded patch because of malformed line endings). Python 3's mail > module uses '\n' internally so the problem doesn't manifest there, but > the content received by Django/JS is still saved in the database with > CRLF line endings which shouldn't be there. Huh, weird. I can't say modifying a sumbission through the admin interface is recommended behaviour, but still worth fixing. Please could you add a comment or docstring to the save function that explains why this is necessary - an abbreviated version of your commit message would be fine. Would you like this queued up for the 2.0.2 stable release? Regards, Daniel > Signed-off-by: Veronika Kabatova <vkabatov@redhat.com> > --- > patchwork/models.py | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/patchwork/models.py b/patchwork/models.py > index 3bf7c72..411af63 100644 > --- a/patchwork/models.py > +++ b/patchwork/models.py > @@ -328,6 +328,10 @@ class EmailMixin(models.Model): > return ''.join([match.group(0) + '\n' for match in > self.response_re.finditer(self.content)]) > > + def save(self, *args, **kwargs): > + self.content = self.content.replace('\r\n', '\n') > + super(EmailMixin, self).save(*args, **kwargs) > + > class Meta: > abstract = True > > -- > 2.13.6 > > _______________________________________________ > Patchwork mailing list > Patchwork@lists.ozlabs.org > https://lists.ozlabs.org/listinfo/patchwork
----- Original Message ----- > From: "Daniel Axtens" <dja@axtens.net> > To: vkabatov@redhat.com, patchwork@lists.ozlabs.org > Sent: Tuesday, February 6, 2018 11:49:15 PM > Subject: Re: [PATCH] Fix CRLF newlines upon submission changes > > Hi Veronika, > > > After changing submission via admin interface, CRLF newlines are > > suddenly present in the body. Replace them back to '\n'. > > > > The issue was found after modifying submission via admin interface > > using Python 2 and downloading the respective mbox file (git choked on > > downloaded patch because of malformed line endings). Python 3's mail > > module uses '\n' internally so the problem doesn't manifest there, but > > the content received by Django/JS is still saved in the database with > > CRLF line endings which shouldn't be there. > > Huh, weird. I can't say modifying a sumbission through the admin > interface is recommended behaviour, but still worth fixing. > > Please could you add a comment or docstring to the save function > that explains why this is necessary - an abbreviated version of your > commit message would be fine. > Hi, I'll add it and resend v2 later today. > Would you like this queued up for the 2.0.2 stable release? > Sure, the more issues fixed for stable releases, the better. Veronika > Regards, > Daniel > > > Signed-off-by: Veronika Kabatova <vkabatov@redhat.com> > > --- > > patchwork/models.py | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/patchwork/models.py b/patchwork/models.py > > index 3bf7c72..411af63 100644 > > --- a/patchwork/models.py > > +++ b/patchwork/models.py > > @@ -328,6 +328,10 @@ class EmailMixin(models.Model): > > return ''.join([match.group(0) + '\n' for match in > > self.response_re.finditer(self.content)]) > > > > + def save(self, *args, **kwargs): > > + self.content = self.content.replace('\r\n', '\n') > > + super(EmailMixin, self).save(*args, **kwargs) > > + > > class Meta: > > abstract = True > > > > -- > > 2.13.6 > > > > _______________________________________________ > > Patchwork mailing list > > Patchwork@lists.ozlabs.org > > https://lists.ozlabs.org/listinfo/patchwork >
diff --git a/patchwork/models.py b/patchwork/models.py index 3bf7c72..411af63 100644 --- a/patchwork/models.py +++ b/patchwork/models.py @@ -328,6 +328,10 @@ class EmailMixin(models.Model): return ''.join([match.group(0) + '\n' for match in self.response_re.finditer(self.content)]) + def save(self, *args, **kwargs): + self.content = self.content.replace('\r\n', '\n') + super(EmailMixin, self).save(*args, **kwargs) + class Meta: abstract = True