From ff51a1a451f12d7c1d7ab4dede19dfb630aeb553 Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Thu, 14 Aug 2014 15:20:45 -0700 Subject: [PATCH] Remarkup - add a regex to blacklist what objects get link Summary: Fixes T5453. Test Plan: made a remarkup comment that "Q1 is dumb and Q10 is awesome" and only Q10 was linked. changed the new setting to have the value " " and the Q1 also started linking. Reviewers: epriestley Reviewed By: epriestley Subscribers: epriestley, Korvin Maniphest Tasks: T5453 Differential Revision: https://secure.phabricator.com/D10270 --- .../config/option/PhabricatorCoreConfigOptions.php | 12 +++++++++++- .../ponder/remarkup/PonderRemarkupRule.php | 12 ------------ src/docs/user/userguide/remarkup.diviner | 10 ++++++---- .../markup/rule/PhabricatorObjectRemarkupRule.php | 6 ++++++ 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/applications/config/option/PhabricatorCoreConfigOptions.php b/src/applications/config/option/PhabricatorCoreConfigOptions.php index 56975bd66f..6d7a66b146 100644 --- a/src/applications/config/option/PhabricatorCoreConfigOptions.php +++ b/src/applications/config/option/PhabricatorCoreConfigOptions.php @@ -120,7 +120,17 @@ final class PhabricatorCoreConfigOptions 'Maniphest. If you\'d prefer more traditional UI strings like '. '"Add Comment", you can set this flag to disable most of the '. 'extra flavor.')), - $this->newOption('environment.append-paths', 'list', $paths) + $this->newOption('remarkup.ignored-object-names', 'string', '/^(Q|V)\d$/') + ->setSummary( + pht('Text values that match this regex and are also object names '. + 'will not be linked.')) + ->setDescription( + pht( + 'By default, Phabricator links object names in Remarkup fields '. + 'to the corresponding object. This regex can be used to modify '. + 'this behavior; object names that match this regex will not be '. + 'linked.')), + $this->newOption('environment.append-paths', 'list', $paths) ->setSummary( pht('These paths get appended to your \$PATH envrionment variable.')) ->setDescription( diff --git a/src/applications/ponder/remarkup/PonderRemarkupRule.php b/src/applications/ponder/remarkup/PonderRemarkupRule.php index 2509e24ade..1de64ab3c4 100644 --- a/src/applications/ponder/remarkup/PonderRemarkupRule.php +++ b/src/applications/ponder/remarkup/PonderRemarkupRule.php @@ -14,16 +14,4 @@ final class PonderRemarkupRule extends PhabricatorObjectRemarkupRule { ->execute(); } - protected function shouldMarkupObject(array $params) { - // NOTE: Q1, Q2, Q3 and Q4 are often used to refer to quarters of the year; - // mark them up only in the {Q1} format. - if ($params['type'] == 'ref') { - if ($params['id'] <= 4) { - return false; - } - } - - return true; - } - } diff --git a/src/docs/user/userguide/remarkup.diviner b/src/docs/user/userguide/remarkup.diviner index 0d1e2c5550..f5b379b80b 100644 --- a/src/docs/user/userguide/remarkup.diviner +++ b/src/docs/user/userguide/remarkup.diviner @@ -297,8 +297,8 @@ Markdown-style links are also supported: = Linking to Objects = -You can link to Differential revisions, Diffusion commits and Maniphest tasks -by mentioning the name of an object: +You can link to Phabricator objects, such as Differential revisions, Diffusion +commits and Maniphest tasks, by mentioning the name of an object: D123 # Link to Differential revision D123 rX123 # Link to SVN commit 123 from the "X" repository @@ -310,6 +310,9 @@ You can also link directly to a comment in Maniphest and Differential: T123#4 # Link to comment #4 of T123 +See the Phabricator configuraton setting `remarkup.ignored-object-names` to +modify this behavior. + = Embedding Objects You can also generate full-name references to some objects by using braces: @@ -411,8 +414,7 @@ If you set a configuration flag, you can embed media directly in text: and have them render inline. This option is disabled by default because it has security and/or -silliness implications. Read the description in `default.conf.php` before -enabling it. +silliness implications. Carefully read the description before enabling it. = Image Macros = diff --git a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php index 3cc7e13c48..fc64eb33fa 100644 --- a/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php +++ b/src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php @@ -158,6 +158,12 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule { return $params['original']; } + $regex = trim( + PhabricatorEnv::getEnvConfig('remarkup.ignored-object-names')); + if ($regex && preg_match($regex, $params['original'])) { + return $params['original']; + } + $engine = $this->getEngine(); $token = $engine->storeText('x');