@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add validation for config settings of type regex

Summary: Also fixes insufficiently-escaped regex examples

Test Plan: Made several changes to http://local.phacility.com/config/edit/syntax.filemap/ and observed validation failures on malformed regexes, and success on well-formed regexes.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12532

Differential Revision: https://secure.phabricator.com/D17684

+26 -4
+2
src/__phutil_library_map__.php
··· 2373 2373 'PhabricatorConfigPageView' => 'applications/config/view/PhabricatorConfigPageView.php', 2374 2374 'PhabricatorConfigProxySource' => 'infrastructure/env/PhabricatorConfigProxySource.php', 2375 2375 'PhabricatorConfigPurgeCacheController' => 'applications/config/controller/PhabricatorConfigPurgeCacheController.php', 2376 + 'PhabricatorConfigRegexOptionType' => 'applications/config/custom/PhabricatorConfigRegexOptionType.php', 2376 2377 'PhabricatorConfigRequestExceptionHandlerModule' => 'applications/config/module/PhabricatorConfigRequestExceptionHandlerModule.php', 2377 2378 'PhabricatorConfigResponse' => 'applications/config/response/PhabricatorConfigResponse.php', 2378 2379 'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php', ··· 7473 7474 'PhabricatorConfigPageView' => 'AphrontTagView', 7474 7475 'PhabricatorConfigProxySource' => 'PhabricatorConfigSource', 7475 7476 'PhabricatorConfigPurgeCacheController' => 'PhabricatorConfigController', 7477 + 'PhabricatorConfigRegexOptionType' => 'PhabricatorConfigJSONOptionType', 7476 7478 'PhabricatorConfigRequestExceptionHandlerModule' => 'PhabricatorConfigModule', 7477 7479 'PhabricatorConfigResponse' => 'AphrontStandaloneHTMLResponse', 7478 7480 'PhabricatorConfigSchemaQuery' => 'Phobject',
+18
src/applications/config/custom/PhabricatorConfigRegexOptionType.php
··· 1 + <?php 2 + 3 + class PhabricatorConfigRegexOptionType 4 + extends PhabricatorConfigJSONOptionType { 5 + 6 + public function validateOption(PhabricatorConfigOption $option, $value) { 7 + foreach ($value as $pattern => $spec) { 8 + $ok = preg_match($pattern, ''); 9 + if ($ok === false) { 10 + throw new Exception( 11 + pht( 12 + 'The following regex is malformed and cannot be used: %s', 13 + $pattern)); 14 + } 15 + } 16 + } 17 + 18 + }
+6 -4
src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
··· 120 120 'this is where that list is defined.')), 121 121 $this->newOption( 122 122 'syntax.filemap', 123 - 'wild', 123 + 'custom:PhabricatorConfigRegexOptionType', 124 124 array( 125 125 '@\.arcconfig$@' => 'json', 126 126 '@\.arclint$@' => 'json', ··· 138 138 'be tested against the filename. They should map to either an '. 139 139 'explicit language as a string value, or a numeric index into '. 140 140 'the captured groups as an integer.')) 141 - ->addExample('{"@\\.xyz$@": "php"}', pht('Highlight %s as PHP.', '*.xyz')) 142 141 ->addExample( 143 - '{"@/httpd\\.conf@": "apacheconf"}', 142 + '{"@\\\.xyz$@": "php"}', 143 + pht('Highlight %s as PHP.', '*.xyz')) 144 + ->addExample( 145 + '{"@/httpd\\\.conf@": "apacheconf"}', 144 146 pht('Highlight httpd.conf as "apacheconf".')) 145 147 ->addExample( 146 - '{"@\\.([^.]+)\\.bak$@": 1}', 148 + '{"@\\\.([^.]+)\\\.bak$@": 1}', 147 149 pht( 148 150 "Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ". 149 151 "1 by specifying the mapping as '1'")),