Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/179785
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(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CommonsMetadata
refs/changes/85/179785/1
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: newchange
Gerrit-Change-Id: I3973a2b18f43c11d8a506bbbaefa7fa675ee82fb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CommonsMetadata
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits