Merge lp:~twom/launchpad/null-controls-cause-errors into lp:launchpad

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: no longer in the source branch.
Merged at revision: 19046
Proposed branch: lp:~twom/launchpad/null-controls-cause-errors
Merge into: lp:launchpad
Diff against target: 63 lines (+18/-2)
3 files modified
lib/lp/soyuz/model/sourcepackagerelease.py (+5/-0)
lib/lp/soyuz/tests/test_sourcepackagerelease.py (+7/-0)
lib/lp/testing/factory.py (+6/-2)
To merge this branch: bzr merge lp:~twom/launchpad/null-controls-cause-errors
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+372343@code.launchpad.net

Commit message

Remove null characters in copyright field of sourcepackagerelease

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
2--- lib/lp/soyuz/model/sourcepackagerelease.py 2017-03-29 09:28:09 +0000
3+++ lib/lp/soyuz/model/sourcepackagerelease.py 2019-09-05 13:59:51 +0000
4@@ -144,6 +144,11 @@
5 if 'copyright' in kwargs:
6 copyright = kwargs.pop('copyright')
7 super(SourcePackageRelease, self).__init__(*args, **kwargs)
8+ # PostgresSQL text columns can't contain null
9+ # characters, so remove them as this is only
10+ # used for display
11+ if copyright is not None:
12+ copyright = copyright.replace("\0", "")
13 self.copyright = copyright
14
15 def __repr__(self):
16
17=== modified file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
18--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 2018-02-02 03:14:35 +0000
19+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2019-09-05 13:59:51 +0000
20@@ -115,3 +115,10 @@
21 observed = spph.sourcepackagerelease.aggregate_changelog(
22 since_version=None)
23 self.assertEqual(changelog_main.decode("UTF-8", "replace"), observed)
24+
25+ def test_null_string_in_copyright(self):
26+ test_string = "test string with null \0 character"
27+ package = self.factory.makeSourcePackageRelease(copyright=test_string)
28+ self.assertEqual(
29+ package.copyright,
30+ "test string with null character")
31
32=== modified file 'lib/lp/testing/factory.py'
33--- lib/lp/testing/factory.py 2019-07-09 12:32:22 +0000
34+++ lib/lp/testing/factory.py 2019-09-05 13:59:51 +0000
35@@ -3719,7 +3719,8 @@
36 user_defined_fields=None,
37 changelog_entry=None,
38 homepage=None,
39- changelog=None):
40+ changelog=None,
41+ copyright=None):
42 """Make a `SourcePackageRelease`."""
43 if distroseries is None:
44 if source_package_recipe_build is not None:
45@@ -3764,6 +3765,9 @@
46 if version is None:
47 version = unicode(self.getUniqueInteger()) + 'version'
48
49+ if copyright is None:
50+ copyright = self.getUniqueString()
51+
52 return distroseries.createUploadedSourcePackageRelease(
53 sourcepackagename=sourcepackagename,
54 maintainer=maintainer,
55@@ -3780,7 +3784,7 @@
56 changelog=changelog,
57 changelog_entry=changelog_entry,
58 dsc=None,
59- copyright=self.getUniqueString(),
60+ copyright=copyright,
61 dscsigningkey=dscsigningkey,
62 dsc_maintainer_rfc822=dsc_maintainer_rfc822,
63 dsc_standards_version=dsc_standards_version,