license-file with extra \n isn't interpreted correctly

Bug #1411677 reported by Andreas Hasenack on 2015-01-16
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Charm
Low
Benji York

Bug Description

If the license-file has a url with a few extra \n:

http://foo.bar/meh\n\n\n

Then the regular expression won't match:
>>> license
'http://foo.bar/meh\n\n\n'
>>> license_file_re
'^(file://|http://|https://).*$'
>>> re.match(license_file_re, license)
>>>

And on the deployed server we will have /etc/landscape/license.txt with that url and the blank lines, instead of its contents.

If we set the MULTILINE flag, then it works:

>>> re.match(license_file_re, license, flags=re.MULTILINE)
<_sre.SRE_Match object at 0x7fd9817f0eb8>

The MULTILINE flag doesn't seem to break when "license" has actual license contents. The regexp won't match then, as expected.

An alternative is to just strip the license when using it in the re.match() method.

>>> re.match(license_file_re, license.strip())
<_sre.SRE_Match object at 0x7fd9838a26c0>

Related branches

tags: removed: kanban
Benji York (benji) on 2015-01-20
Changed in landscape-charm:
assignee: nobody → Benji York (benji)
Benji York (benji) on 2015-01-21
Changed in landscape-charm:
status: New → In Progress
Changed in landscape-charm:
status: In Progress → Fix Committed
Changed in landscape-charm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers