diff --git a/src/applications/config/controller/PhabricatorConfigEditController.php b/src/applications/config/controller/PhabricatorConfigEditController.php index 316cee69b2..3476a9c056 100644 --- a/src/applications/config/controller/PhabricatorConfigEditController.php +++ b/src/applications/config/controller/PhabricatorConfigEditController.php @@ -258,6 +258,9 @@ final class PhabricatorConfigEditController case 'list': $set_value = $request->getStrList('value'); break; + case 'set': + $set_value = array_fill_keys($request->getStrList('value'), true); + break; case 'bool': switch ($value) { case 'true': @@ -329,6 +332,8 @@ final class PhabricatorConfigEditController return $value ? 'true' : 'false'; case 'list': return implode("\n", nonempty($value, array())); + case 'set': + return implode("\n", nonempty(array_keys($value), array())); default: return PhabricatorConfigJSON::prettyPrintJSON($value); } @@ -370,6 +375,7 @@ final class PhabricatorConfigEditController ->setOptions($names); break; case 'list': + case 'set': $control = id(new AphrontFormTextAreaControl()) ->setCaption(pht('Separate values with newlines or commas.')); break; diff --git a/src/applications/config/json/PhabricatorConfigJSON.php b/src/applications/config/json/PhabricatorConfigJSON.php index 2027533a20..2e82d1297f 100644 --- a/src/applications/config/json/PhabricatorConfigJSON.php +++ b/src/applications/config/json/PhabricatorConfigJSON.php @@ -11,15 +11,17 @@ final class PhabricatorConfigJSON { // Check not only that it's an array, but that it's an "unnatural" array // meaning that the keys aren't 0 -> size_of_array. if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) { - return id(new PhutilJSON())->encodeFormatted($value); + $result = id(new PhutilJSON())->encodeFormatted($value); } else { $result = json_encode($value); - // For readability, unescape forward slashes. These are normally escaped - // to prevent the string "" from appearing in a JSON literal, - // but it's irrelevant here and makes reading paths more difficult than - // necessary. - $result = str_replace('\\/', '/', $result); - return $result; } + + // For readability, unescape forward slashes. These are normally escaped + // to prevent the string "" from appearing in a JSON literal, + // but it's irrelevant here and makes reading paths more difficult than + // necessary. + $result = str_replace('\\/', '/', $result); + return $result; + } } diff --git a/src/applications/config/option/PhabricatorApplicationConfigOptions.php b/src/applications/config/option/PhabricatorApplicationConfigOptions.php index 9bd6d402db..8c14f42370 100644 --- a/src/applications/config/option/PhabricatorApplicationConfigOptions.php +++ b/src/applications/config/option/PhabricatorApplicationConfigOptions.php @@ -56,6 +56,24 @@ abstract class PhabricatorApplicationConfigOptions extends Phobject { $option->getBaseClass())); } break; + case 'set': + $valid = true; + if (!is_array($value)) { + throw new PhabricatorConfigValidationException( + pht( + "Option '%s' must be a set, but value is not an array.", + $option->getKey())); + } + foreach ($value as $v) { + if ($v !== true) { + throw new PhabricatorConfigValidationException( + pht( + "Option '%s' must be a set, but array contains values other ". + "than 'true'.", + $option->getKey())); + } + } + break; case 'list': $valid = true; if (!is_array($value)) { diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php index ad5040d4cc..07bf393581 100644 --- a/src/applications/config/option/PhabricatorCoreConfigOptions.php +++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php @@ -106,13 +106,13 @@ final class PhabricatorCoreConfigOptions "then playing with a user tokenizer (like the user selectors in ". "Maniphest or Differential) and seeing which setting loads ". "faster and feels better.")), - $this->newOption('config.lock', 'wild', array()) + $this->newOption('config.lock', 'set', array()) ->setLocked(true) ->setDescription(pht('Additional configuration options to lock.')), - $this->newOption('config.hide', 'wild', array()) + $this->newOption('config.hide', 'set', array()) ->setLocked(true) ->setDescription(pht('Additional configuration options to hide.')), - $this->newOption('config.mask', 'wild', array()) + $this->newOption('config.mask', 'set', array()) ->setLocked(true) ->setDescription(pht('Additional configuration options to mask.')), ); diff --git a/src/applications/config/option/PhabricatorSecurityConfigOptions.php b/src/applications/config/option/PhabricatorSecurityConfigOptions.php index 7225bf3e0e..44f4e1bb8f 100644 --- a/src/applications/config/option/PhabricatorSecurityConfigOptions.php +++ b/src/applications/config/option/PhabricatorSecurityConfigOptions.php @@ -40,6 +40,7 @@ final class PhabricatorSecurityConfigOptions 'security.hmac-key', 'string', '[D\t~Y7eNmnQGJ;rnH6aF;m2!vJ8@v8C=Cs:aQS\.Qw') + ->setMasked(true) ->setSummary( pht("Key for HMAC digests.")) ->setDescription( @@ -82,6 +83,7 @@ final class PhabricatorSecurityConfigOptions 'phabricator.csrf-key', 'string', '0b7ec0592e0a2829d8b71df2fa269b2c6172eca3') + ->setMasked(true) ->setSummary( pht("Hashed with other inputs to generate CSRF tokens.")) ->setDescription( @@ -96,6 +98,7 @@ final class PhabricatorSecurityConfigOptions 'phabricator.mail-key', 'string', '5ce3e7e8787f6e40dfae861da315a5cdf1018f12') + ->setMasked(true) ->setSummary( pht("Hashed with other inputs to generate mail tokens.")) ->setDescription( @@ -105,9 +108,7 @@ final class PhabricatorSecurityConfigOptions "unique to your install. In particular, you will want to do ". "this if you accidentally send a bunch of mail somewhere you ". "shouldn't have, to invalidate all old reply-to addresses.")), - // TODO: This should really be dict but that doesn't exist - // yet. - $this->newOption('uri.allowed-protocols', 'wild', null) + $this->newOption('uri.allowed-protocols', 'set', null) ->setSummary( pht("Determines which URI protocols are auto-linked.")) ->setDescription( diff --git a/src/applications/files/config/PhabricatorFilesConfigOptions.php b/src/applications/files/config/PhabricatorFilesConfigOptions.php index a561154f6c..b960cd6ee5 100644 --- a/src/applications/files/config/PhabricatorFilesConfigOptions.php +++ b/src/applications/files/config/PhabricatorFilesConfigOptions.php @@ -52,7 +52,7 @@ final class PhabricatorFilesConfigOptions 'The keys in this map are vieweable MIME types; the values are '. 'the MIME type sthey are delivered as when they are viewed in '. 'the browser.')), - $this->newOption('files.image-mime-types', 'wild', $image_default) + $this->newOption('files.image-mime-types', 'set', $image_default) ->setSummary(pht('Configure which MIME types are images.')) ->setDescription( pht(