Skip to content

Commit 8a8fba0

Browse files
Fix binary gibberish bug on extra newlines
Regen test expectations for this and also fix another test. Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent a7cc2d5 commit 8a8fba0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+99
-145
lines changed

src/licensedcode/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def load(self, license_file, check_consistency=True):
463463

464464
self.text = ''
465465
else:
466-
self.text = post.content
466+
self.text = post.content.lstrip()
467467

468468
for k, v in data.items():
469469
if k == 'minimum_coverage':
@@ -1927,7 +1927,7 @@ def load(self, rule_file, with_checks=True):
19271927
f'{self}: file://{rule_file}'
19281928
)
19291929

1930-
self.text = post.content
1930+
self.text = post.content.lstrip()
19311931

19321932
except Exception as e:
19331933
print('#############################')

tests/licensedcode/data/license_db/index.json-expected.json

+12-12
Large diffs are not rendered by default.

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ text_urls:
1111
- https://git.savannah.gnu.org/cgit/bash.git/plain/COPYING?h=bash-3.0-rc1&id=dd9e6dfa23d0dae4888f11fb8c6a27bc36d1b283
1212
---
1313

14-
b'\nThe Free Software Foundation has exempted Bash from the requirement of\nParagraph 2c of the General Public License. This is to say, there is\nno requirement for Bash to print a notice when it is started\ninteractively in the usual way. We made this exception because users\nand standards expect shells not to print such messages. This\nexception applies to any program that serves as a shell and that is\nbased primarily on Bash as opposed to other GNU software.'
14+
b'The Free Software Foundation has exempted Bash from the requirement of\nParagraph 2c of the General Public License. This is to say, there is\nno requirement for Bash to print a notice when it is started\ninteractively in the usual way. We made this exception because users\nand standards expect shells not to print such messages. This\nexception applies to any program that serves as a shell and that is\nbased primarily on Bash as opposed to other GNU software.'

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@
132132
<dt style="">text</dt>
133133
<dd>
134134

135-
136-
The Free Software Foundation has exempted Bash from the requirement of
135+
The Free Software Foundation has exempted Bash from the requirement of
137136
Paragraph 2c of the General Public License. This is to say, there is
138137
no requirement for Bash to print a notice when it is started
139138
interactively in the usual way. We made this exception because users
@@ -145,8 +144,7 @@
145144

146145
</dl>
147146
<div class="text-bold">license_text</div>
148-
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>
149-
The Free Software Foundation has exempted Bash from the requirement of
147+
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>The Free Software Foundation has exempted Bash from the requirement of
150148
Paragraph 2c of the General Public License. This is to say, there is
151149
no requirement for Bash to print a notice when it is started
152150
interactively in the usual way. We made this exception because users
@@ -164,7 +162,7 @@
164162
<a href="https://www.aboutcode.org/" target="_blank">AboutCode</a>
165163
</p>
166164
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
167-
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.1.0 on Sep 28, 2022.</p>
165+
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.2.1 on Oct 14, 2022.</p>
168166
</footer>
169167
</div>
170168

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"text_urls": [
1111
"https://git.savannah.gnu.org/cgit/bash.git/plain/COPYING?h=bash-3.0-rc1&id=dd9e6dfa23d0dae4888f11fb8c6a27bc36d1b283"
1212
],
13-
"text": "\nThe Free Software Foundation has exempted Bash from the requirement of\nParagraph 2c of the General Public License. This is to say, there is\nno requirement for Bash to print a notice when it is started\ninteractively in the usual way. We made this exception because users\nand standards expect shells not to print such messages. This\nexception applies to any program that serves as a shell and that is\nbased primarily on Bash as opposed to other GNU software."
13+
"text": "The Free Software Foundation has exempted Bash from the requirement of\nParagraph 2c of the General Public License. This is to say, there is\nno requirement for Bash to print a notice when it is started\ninteractively in the usual way. We made this exception because users\nand standards expect shells not to print such messages. This\nexception applies to any program that serves as a shell and that is\nbased primarily on Bash as opposed to other GNU software."
1414
}

tests/licensedcode/data/license_db/license_dump/bash-exception-gpl.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ spdx_license_key: LicenseRef-scancode-bash-exception-gpl-2.0
99
text_urls:
1010
- https://git.savannah.gnu.org/cgit/bash.git/plain/COPYING?h=bash-3.0-rc1&id=dd9e6dfa23d0dae4888f11fb8c6a27bc36d1b283
1111
text: |
12-
1312
The Free Software Foundation has exempted Bash from the requirement of
1413
Paragraph 2c of the General Public License. This is to say, there is
1514
no requirement for Bash to print a notice when it is started

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ homepage_url: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-fir
88
spdx_license_key: LicenseRef-scancode-binary-linux-firmware
99
---
1010

11-
b'\nRedistribution. Redistribution and use in binary form, without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions must reproduce the above copyright notice and the\nfollowing disclaimer in the documentation and/or other materials\nprovided with the distribution.\n\n* Neither the name of the Copyright Holder nor the names of its\nsuppliers may be used to endorse or promote products derived from this\nsoftware without specific prior written permission.\n\n* No reverse engineering, decompilation, or disassembly of this software\nis permitted.\n\nDISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\nCONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE'
11+
b'Redistribution. Redistribution and use in binary form, without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions must reproduce the above copyright notice and the\nfollowing disclaimer in the documentation and/or other materials\nprovided with the distribution.\n\n* Neither the name of the Copyright Holder nor the names of its\nsuppliers may be used to endorse or promote products derived from this\nsoftware without specific prior written permission.\n\n* No reverse engineering, decompilation, or disassembly of this software\nis permitted.\n\nDISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\nCONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE'

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@
116116
<dt style="">text</dt>
117117
<dd>
118118

119-
120-
Redistribution. Redistribution and use in binary form, without
119+
Redistribution. Redistribution and use in binary form, without
121120
modification, are permitted provided that the following conditions are
122121
met:
123122

@@ -148,8 +147,7 @@
148147

149148
</dl>
150149
<div class="text-bold">license_text</div>
151-
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>
152-
Redistribution. Redistribution and use in binary form, without
150+
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>Redistribution. Redistribution and use in binary form, without
153151
modification, are permitted provided that the following conditions are
154152
met:
155153

@@ -186,7 +184,7 @@
186184
<a href="https://www.aboutcode.org/" target="_blank">AboutCode</a>
187185
</p>
188186
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
189-
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.1.0 on Sep 28, 2022.</p>
187+
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.2.1 on Oct 14, 2022.</p>
190188
</footer>
191189
</div>
192190

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
"owner": "Unspecified",
77
"homepage_url": "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/",
88
"spdx_license_key": "LicenseRef-scancode-binary-linux-firmware",
9-
"text": "\nRedistribution. Redistribution and use in binary form, without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions must reproduce the above copyright notice and the\nfollowing disclaimer in the documentation and/or other materials\nprovided with the distribution.\n\n* Neither the name of the Copyright Holder nor the names of its\nsuppliers may be used to endorse or promote products derived from this\nsoftware without specific prior written permission.\n\n* No reverse engineering, decompilation, or disassembly of this software\nis permitted.\n\nDISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\nCONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE"
9+
"text": "Redistribution. Redistribution and use in binary form, without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions must reproduce the above copyright notice and the\nfollowing disclaimer in the documentation and/or other materials\nprovided with the distribution.\n\n* Neither the name of the Copyright Holder nor the names of its\nsuppliers may be used to endorse or promote products derived from this\nsoftware without specific prior written permission.\n\n* No reverse engineering, decompilation, or disassembly of this software\nis permitted.\n\nDISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND\nCONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\nBUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\nFITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF\nUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE"
1010
}

tests/licensedcode/data/license_db/license_dump/binary-linux-firmware.yml

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ owner: Unspecified
66
homepage_url: https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/
77
spdx_license_key: LicenseRef-scancode-binary-linux-firmware
88
text: |
9-
109
Redistribution. Redistribution and use in binary form, without
1110
modification, are permitted provided that the following conditions are
1211
met:

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ standard_notice: |
2525
Bison.
2626
---
2727

28-
b'\nAs a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.'
28+
b'As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.'

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.html

+3-5
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,13 @@
145145
<dt style="">text</dt>
146146
<dd>
147147

148-
149-
As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.
148+
As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.
150149

151150
</dd>
152151

153152
</dl>
154153
<div class="text-bold">license_text</div>
155-
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>
156-
As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.</code></pre>
154+
<pre id="license-text" class="code mt-1" style="white-space: pre-wrap;"><code>As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.</code></pre>
157155
</div>
158156

159157
<div class="container">
@@ -165,7 +163,7 @@
165163
<a href="https://www.aboutcode.org/" target="_blank">AboutCode</a>
166164
</p>
167165
<p>Designed and built by <a href="https://www.nexb.com/" target="_blank">nexB</a>. Licensed under the <a href="cc-by-4.0.html">Creative Commons Attribution License 4.0 (CC-BY-4.0)</a>.</p>
168-
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.1.0 on Sep 28, 2022.</p>
166+
<p>Generated with <a href="https://github.com/nexB/scancode-toolkit" target="_blank">ScanCode toolkit</a> 31.2.1 on Oct 14, 2022.</p>
169167
</footer>
170168
</div>
171169

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"spdx_license_key": "LicenseRef-scancode-bison-exception-2.0",
99
"faq_url": "http://www.gnu.org/software/bison/manual/bison.html#Conditions",
1010
"standard_notice": "This library is free software; you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the Free\nSoftware Foundation; either version 2, or (at your option) any later\nversion.\nThis library is distributed in the hope that it will be useful, but WITHOUT\nANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\nFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\nmore details.\nYou should have received a copy of the GNU General Public License along\nwith this library; see the file COPYING. If not, write to the Free Software\nFoundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\nAs a special exception, when this file is copied by Bison into a Bison\noutput file, you may use that output file without restriction. This special\nexception was added by the Free Software Foundation in version 1.24 of\nBison.\n",
11-
"text": "\nAs a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison."
11+
"text": "As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison."
1212
}

tests/licensedcode/data/license_db/license_dump/bison-exception-2.0.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ standard_notice: |
2222
output file, you may use that output file without restriction. This special
2323
exception was added by the Free Software Foundation in version 1.24 of
2424
Bison.
25-
text: |
26-
27-
As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison.
25+
text: As a special exception, when this file is copied by Bison into a Bison output file, you
26+
may use that output file without restriction. This special exception was added by the Free
27+
Software Foundation in version 1.24 of Bison.

tests/licensedcode/data/license_db/license_dump/bison-exception-2.2.LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ standard_notice: |
3535
2.2 of Bison.
3636
---
3737

38-
b"\nAs a special exception, you may create a larger work that contains part or all\nof the Bison parser skeleton and distribute that work under terms of your\nchoice, so long as that work isn't itself a parser generator using the skeleton\nor a modified version thereof as a parser skeleton. Alternatively, if you\nmodify or redistribute the parser skeleton itself, you may (at your option)\nremove this special exception, which will cause the skeleton and the resulting\nBison output files to be licensed under the GNU General Public License without\nthis special exception.\n\nThis special exception was added by the Free Software Foundation in version 2.2\nof Bison."
38+
b"As a special exception, you may create a larger work that contains part or all\nof the Bison parser skeleton and distribute that work under terms of your\nchoice, so long as that work isn't itself a parser generator using the skeleton\nor a modified version thereof as a parser skeleton. Alternatively, if you\nmodify or redistribute the parser skeleton itself, you may (at your option)\nremove this special exception, which will cause the skeleton and the resulting\nBison output files to be licensed under the GNU General Public License without\nthis special exception.\n\nThis special exception was added by the Free Software Foundation in version 2.2\nof Bison."

0 commit comments

Comments
 (0)