diff --git a/includes/Traits/License_Utils.php b/includes/Traits/License_Utils.php index 5915c00cb..f13e4eb6c 100644 --- a/includes/Traits/License_Utils.php +++ b/includes/Traits/License_Utils.php @@ -57,6 +57,8 @@ protected function get_normalized_license( $license ) { $license = preg_replace( '/EUPL\s*[-|\.]*\s*[v]?([0-9]+)(\.[0-9]+)?/i', 'EUPL', $license ); $license = preg_replace( '/Apache.*?([0-9])(\.[0])?/i', 'Apache$1', $license ); $license = preg_replace( '/(The\s+)?Unlicense/i', 'Unlicense', $license ); + // Normalize Zero-Clause BSD variations (e.g., "Zero-Clause BSD", "BSD Zero Clause License", "BSD-0-Clause"). + $license = preg_replace( '/BSD\s*(Zero|0)\s*Clause(\s+License)?|(Zero|0)\s*Clause\s+BSD(\s+License)?/i', '0BSD', $license ); $license = preg_replace( '/Blue\s*Oak(\s+Model\s+License)?(\s*[v]?[0-9\.]+)?/i', 'BlueOak', $license ); // Normalize WTFPL variations - must come before version removal to catch full text. $license = preg_replace( '/Do\s+What\s+The\s+F[^\s]*\s+You\s+Want\s+To\s+Public\s+License/i', 'WTFPL', $license ); @@ -96,7 +98,7 @@ protected function is_license_gpl_compatible( $license ) { return true; } - $match = preg_match( '/GPL|EUPL|GNU|MIT|FreeBSD|New BSD|BSD-3-Clause|BSD 3 Clause|OpenLDAP|Expat|Apache2|MPL20|ISC|CC0|Unlicense|WTFPL|BlueOak/im', $license ); + $match = preg_match( '/GPL|EUPL|GNU|MIT|FreeBSD|New BSD|0BSD|BSD[\s\-]*[23][\s\-]*Clause|OpenLDAP|Expat|Apache2|MPL20|ISC|CC0|Unlicense|WTFPL|BlueOak/im', $license ); return ( false === $match || 0 === $match ) ? false : true; } diff --git a/tests/phpunit/tests/Traits/License_Utils_Tests.php b/tests/phpunit/tests/Traits/License_Utils_Tests.php index 565b77475..b57a53da5 100644 --- a/tests/phpunit/tests/Traits/License_Utils_Tests.php +++ b/tests/phpunit/tests/Traits/License_Utils_Tests.php @@ -91,6 +91,12 @@ public function data_licenses_for_normalization() { array( 'Do What The F*ck You Want To Public License', 'WTFPL' ), array( 'Do What The Fuck You Want To Public License', 'WTFPL' ), + + array( '0BSD', '0BSD' ), + array( 'Zero-Clause BSD', '0BSD' ), + array( 'BSD Zero Clause License', '0BSD' ), + array( 'BSD-0-Clause', '0BSD' ), + array( '0-clause BSD', '0BSD' ), ); } @@ -107,6 +113,7 @@ public function data_license_identifiers() { array( 'EUPL-1.2', true ), array( 'AGPL-3.0-only', true ), array( 'BlueOak-1.0.0', true ), + array( '0BSD', true ), array( 'MIT License', false ), array( 'GPL (v3)', false ), @@ -143,11 +150,17 @@ public function data_license_gpl_compatibility() { array( 'EUPL-1.2', true ), array( 'BlueOak', true ), array( 'BlueOak-1.0.0', true ), + array( '0BSD', true ), + array( 'BSD2Clause', true ), + array( 'BSD3Clause', true ), + array( 'BSD-2-Clause', true ), + array( 'BSD 2 Clause', true ), array( 'EPL', false ), array( 'MPL10', false ), array( 'YPL', false ), array( 'ZPL', false ), + array( 'BSD4Clause', false ), ); } }