Skip to content

Commit

Permalink
Improve recognition for Apache 1.1 & 2.0
Browse files Browse the repository at this point in the history
Add more test inputs for the two Apache licenses, taking into account
what is presented as example or suggested in the official web pages
about the two licenses:

- https://www.apache.org/licenses/LICENSE-1.1
- https://www.apache.org/licenses/LICENSE-2.0#apply

This should hopefully cover the "actual" request in GH #72
(#72).

The added tests both fail, hence the proposed changes to the relevant
`@phrases` inside Software::LicenseUtils, as well as a cleanup.
  • Loading branch information
polettix committed Aug 25, 2024
1 parent 9c24aeb commit 57c0c56
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/Software/LicenseUtils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ my @phrases = (
'has dedicated the work to the Commons' => 'CC0_1_0',
'waiving all of his or her rights to the work worldwide under copyright law' => 'CC0_1_0',
'has waived all copyright and related or neighboring rights to' => 'CC0_1_0',
'apache(?: |-)1.1' => "Apache_1_1",
"Apache Software License(\\s)+Version 1.1" => "Apache_1_1",
'apache(?: |-)2.0' => "Apache_2_0",
"Apache License(\\s)+Version 2.0" => "Apache_2_0",
'apache[- ]1.1' => "Apache_1_1",
"Apache Software License[,\\s]+Version 1.1" => "Apache_1_1",
'apache[- ]2.0' => "Apache_2_0",
"Apache License[,\\s]+Version 2.0" => "Apache_2_0",
'No license is granted to other entities' => 'None',
);

Expand Down
31 changes: 31 additions & 0 deletions t/guess_license_from_pod.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,18 @@ Version 1.1
Copyright (c) 2000 The Apache Software Foundation. All rights reserved.
LICENSE

# https://www.apache.org/licenses/LICENSE-1.1
# "An example Apache Software License 1.1 file"
my $license_as_example = <<'LICENSE_AS_EXAMPLE';
The Apache Software License, Version 1.1
Copyright (c) 2000 The Apache Software Foundation. All rights
reserved.
LICENSE_AS_EXAMPLE

my @license_strings = (
$license,
$license_as_example,
"apache 1.1", "Apache 1.1", "APACHE 1.1",
"apache-1.1", "Apache-1.1", "APACHE-1.1",
);
Expand All @@ -78,8 +88,29 @@ subtest 'apache_2_0' => sub {
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
LICENSE

# https://www.apache.org/licenses/LICENSE-2.0 suggests:
#
# To apply the Apache License to specific files in your work, attach
# the following boilerplate declaration, ...
my $boilerplate = << 'BOILERPLATE';
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
BOILERPLATE

my @license_strings = (
$license,
$boilerplate,
"apache 2.0", "Apache 2.0", "APACHE 2.0",
"apache-2.0", "Apache-2.0", "APACHE-2.0",
);
Expand Down

0 comments on commit 57c0c56

Please sign in to comment.