1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-19 03:01:11 +01:00

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
This commit is contained in:
Bob Trahan 2014-08-14 15:20:45 -07:00
parent f8af89a99e
commit ff51a1a451
4 changed files with 23 additions and 17 deletions

View file

@ -120,6 +120,16 @@ final class PhabricatorCoreConfigOptions
'Maniphest. If you\'d prefer more traditional UI strings like '. 'Maniphest. If you\'d prefer more traditional UI strings like '.
'"Add Comment", you can set this flag to disable most of the '. '"Add Comment", you can set this flag to disable most of the '.
'extra flavor.')), 'extra flavor.')),
$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<string>', $paths) $this->newOption('environment.append-paths', 'list<string>', $paths)
->setSummary( ->setSummary(
pht('These paths get appended to your \$PATH envrionment variable.')) pht('These paths get appended to your \$PATH envrionment variable.'))

View file

@ -14,16 +14,4 @@ final class PonderRemarkupRule extends PhabricatorObjectRemarkupRule {
->execute(); ->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;
}
} }

View file

@ -297,8 +297,8 @@ Markdown-style links are also supported:
= Linking to Objects = = Linking to Objects =
You can link to Differential revisions, Diffusion commits and Maniphest tasks You can link to Phabricator objects, such as Differential revisions, Diffusion
by mentioning the name of an object: commits and Maniphest tasks, by mentioning the name of an object:
D123 # Link to Differential revision D123 D123 # Link to Differential revision D123
rX123 # Link to SVN commit 123 from the "X" repository 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 T123#4 # Link to comment #4 of T123
See the Phabricator configuraton setting `remarkup.ignored-object-names` to
modify this behavior.
= Embedding Objects = Embedding Objects
You can also generate full-name references to some objects by using braces: 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. and have them render inline.
This option is disabled by default because it has security and/or This option is disabled by default because it has security and/or
silliness implications. Read the description in `default.conf.php` before silliness implications. Carefully read the description before enabling it.
enabling it.
= Image Macros = = Image Macros =

View file

@ -158,6 +158,12 @@ abstract class PhabricatorObjectRemarkupRule extends PhutilRemarkupRule {
return $params['original']; return $params['original'];
} }
$regex = trim(
PhabricatorEnv::getEnvConfig('remarkup.ignored-object-names'));
if ($regex && preg_match($regex, $params['original'])) {
return $params['original'];
}
$engine = $this->getEngine(); $engine = $this->getEngine();
$token = $engine->storeText('x'); $token = $engine->storeText('x');