jenkins-bot has submitted this change and it was merged.

Change subject: Make sure spaces in CC license shortnames are handled correctly
......................................................................


Make sure spaces in CC license shortnames are handled correctly

Bug: T78433
Change-Id: I3973a2b18f43c11d8a506bbbaefa7fa675ee82fb
---
M LicenseParser.php
M tests/phpunit/LicenseParserTest.php
2 files changed, 9 insertions(+), 1 deletion(-)

Approvals:
  Gilles: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/LicenseParser.php b/LicenseParser.php
index b67a684..a619ef5 100644
--- a/LicenseParser.php
+++ b/LicenseParser.php
@@ -96,7 +96,7 @@
                        return $data;
                }
 
-               $parts = explode( '-', $str );
+               $parts = preg_split( '/[- ]/', $str );
                if ( $parts[0] != 'cc' ) {
                        return null;
                }
diff --git a/tests/phpunit/LicenseParserTest.php 
b/tests/phpunit/LicenseParserTest.php
index 3cb08af..d81a60c 100644
--- a/tests/phpunit/LicenseParserTest.php
+++ b/tests/phpunit/LicenseParserTest.php
@@ -61,6 +61,14 @@
                $this->assertLicenseNameEquals( 'cc-by-sa-1.0', $data );
        }
 
+       public function testNormalCCLicenseWithSpaces() {
+               $licenseString = 'CC BY-SA 1.0';
+               $data = $this->licenseParser->parseLicenseString( 
$licenseString );
+               $this->assertLicenseFamilyEquals( 'cc', $data );
+               $this->assertLicenseTypeEquals( 'cc-by-sa', $data );
+               $this->assertLicenseNameEquals( 'cc-by-sa-1.0', $data );
+       }
+
        public function testCCSALicense() {
                $licenseString = 'CC-SA-1.0';
                $data = $this->licenseParser->parseLicenseString( 
$licenseString );

-- 
To view, visit https://gerrit.wikimedia.org/r/179785
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3973a2b18f43c11d8a506bbbaefa7fa675ee82fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CommonsMetadata
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Gilles <gdu...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to