Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15198654
D17684.id42532.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D17684.id42532.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2373,6 +2373,7 @@
'PhabricatorConfigPageView' => 'applications/config/view/PhabricatorConfigPageView.php',
'PhabricatorConfigProxySource' => 'infrastructure/env/PhabricatorConfigProxySource.php',
'PhabricatorConfigPurgeCacheController' => 'applications/config/controller/PhabricatorConfigPurgeCacheController.php',
+ 'PhabricatorConfigRegexOptionType' => 'applications/config/custom/PhabricatorConfigRegexOptionType.php',
'PhabricatorConfigRequestExceptionHandlerModule' => 'applications/config/module/PhabricatorConfigRequestExceptionHandlerModule.php',
'PhabricatorConfigResponse' => 'applications/config/response/PhabricatorConfigResponse.php',
'PhabricatorConfigSchemaQuery' => 'applications/config/schema/PhabricatorConfigSchemaQuery.php',
@@ -7473,6 +7474,7 @@
'PhabricatorConfigPageView' => 'AphrontTagView',
'PhabricatorConfigProxySource' => 'PhabricatorConfigSource',
'PhabricatorConfigPurgeCacheController' => 'PhabricatorConfigController',
+ 'PhabricatorConfigRegexOptionType' => 'PhabricatorConfigJSONOptionType',
'PhabricatorConfigRequestExceptionHandlerModule' => 'PhabricatorConfigModule',
'PhabricatorConfigResponse' => 'AphrontStandaloneHTMLResponse',
'PhabricatorConfigSchemaQuery' => 'Phobject',
diff --git a/src/applications/config/custom/PhabricatorConfigRegexOptionType.php b/src/applications/config/custom/PhabricatorConfigRegexOptionType.php
new file mode 100644
--- /dev/null
+++ b/src/applications/config/custom/PhabricatorConfigRegexOptionType.php
@@ -0,0 +1,18 @@
+<?php
+
+class PhabricatorConfigRegexOptionType
+ extends PhabricatorConfigJSONOptionType {
+
+ public function validateOption(PhabricatorConfigOption $option, $value) {
+ foreach ($value as $pattern => $spec) {
+ $ok = preg_match($pattern, '');
+ if ($ok === false) {
+ throw new Exception(
+ pht(
+ 'The following regex is malformed and cannot be used: %s',
+ $pattern));
+ }
+ }
+ }
+
+}
diff --git a/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php b/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
--- a/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
+++ b/src/applications/config/option/PhabricatorSyntaxHighlightingConfigOptions.php
@@ -120,7 +120,7 @@
'this is where that list is defined.')),
$this->newOption(
'syntax.filemap',
- 'wild',
+ 'custom:PhabricatorConfigRegexOptionType',
array(
'@\.arcconfig$@' => 'json',
'@\.arclint$@' => 'json',
@@ -138,12 +138,14 @@
'be tested against the filename. They should map to either an '.
'explicit language as a string value, or a numeric index into '.
'the captured groups as an integer.'))
- ->addExample('{"@\\.xyz$@": "php"}', pht('Highlight %s as PHP.', '*.xyz'))
->addExample(
- '{"@/httpd\\.conf@": "apacheconf"}',
+ '{"@\\\.xyz$@": "php"}',
+ pht('Highlight %s as PHP.', '*.xyz'))
+ ->addExample(
+ '{"@/httpd\\\.conf@": "apacheconf"}',
pht('Highlight httpd.conf as "apacheconf".'))
->addExample(
- '{"@\\.([^.]+)\\.bak$@": 1}',
+ '{"@\\\.([^.]+)\\\.bak$@": 1}',
pht(
"Treat all '*.x.bak' file as '.x'. NOTE: We map to capturing group ".
"1 by specifying the mapping as '1'")),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 24, 4:19 AM (13 h, 1 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7188739
Default Alt Text
D17684.id42532.diff (3 KB)
Attached To
Mode
D17684: Add validation for config settings of type regex
Attached
Detach File
Event Timeline
Log In to Comment