From e43d0b5a5b8dec50464c907bf837e673f50e1de2 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Sun, 24 Feb 2013 18:33:06 +0100 Subject: [PATCH] Allow for "proprietary" as license identifier --- doc/04-schema.md | 2 ++ src/Composer/Util/ConfigValidator.php | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/04-schema.md b/doc/04-schema.md index f4422549b..2742612a0 100644 --- a/doc/04-schema.md +++ b/doc/04-schema.md @@ -150,6 +150,8 @@ The recommended notation for the most common licenses is (alphabetical): Optional, but it is highly recommended to supply this. More identifiers are listed at the [SPDX Open Source License Registry](http://www.spdx.org/licenses/). +For closed-source software, you may use `"proprietary"` as the license identifier. + An Example: { diff --git a/src/Composer/Util/ConfigValidator.php b/src/Composer/Util/ConfigValidator.php index 0d8cb3762..c7e5d2907 100644 --- a/src/Composer/Util/ConfigValidator.php +++ b/src/Composer/Util/ConfigValidator.php @@ -74,15 +74,25 @@ class ConfigValidator // validate actual data if (!empty($manifest['license'])) { + // strip proprietary since it's not a valid SPDX identifier, but is accepted by composer + if (is_array($manifest['license'])) { + foreach ($manifest['license'] as $key => $license) { + if ('proprietary' === $license) { + unset($manifest['license'][$key]); + } + } + } + $licenseValidator = new SpdxLicenseIdentifier(); - if (!$licenseValidator->validate($manifest['license'])) { + if ('proprietary' !== $manifest['license'] && array() !== $manifest['license'] && !$licenseValidator->validate($manifest['license'])) { $warnings[] = sprintf( - 'License %s is not a valid SPDX license identifier, see http://www.spdx.org/licenses/ if you use an open license', + 'License %s is not a valid SPDX license identifier, see http://www.spdx.org/licenses/ if you use an open license.' + ."\nIf the software is closed-source, you may use \"proprietary\" as license.", json_encode($manifest['license']) ); } } else { - $warnings[] = 'No license specified, it is recommended to do so'; + $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.'; } if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {