Page MenuHomePhabricator

D17684.id42532.diff
No OneTemporary

D17684.id42532.diff

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

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)

Event Timeline