Skip to content

Commit ff51a1a

Browse files
committed
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
1 parent f8af89a commit ff51a1a

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

src/applications/config/option/PhabricatorCoreConfigOptions.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,17 @@ public function getOptions() {
120120
'Maniphest. If you\'d prefer more traditional UI strings like '.
121121
'"Add Comment", you can set this flag to disable most of the '.
122122
'extra flavor.')),
123-
$this->newOption('environment.append-paths', 'list<string>', $paths)
123+
$this->newOption('remarkup.ignored-object-names', 'string', '/^(Q|V)\d$/')
124+
->setSummary(
125+
pht('Text values that match this regex and are also object names '.
126+
'will not be linked.'))
127+
->setDescription(
128+
pht(
129+
'By default, Phabricator links object names in Remarkup fields '.
130+
'to the corresponding object. This regex can be used to modify '.
131+
'this behavior; object names that match this regex will not be '.
132+
'linked.')),
133+
$this->newOption('environment.append-paths', 'list<string>', $paths)
124134
->setSummary(
125135
pht('These paths get appended to your \$PATH envrionment variable.'))
126136
->setDescription(

src/applications/ponder/remarkup/PonderRemarkupRule.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,4 @@ protected function loadObjects(array $ids) {
1414
->execute();
1515
}
1616

17-
protected function shouldMarkupObject(array $params) {
18-
// NOTE: Q1, Q2, Q3 and Q4 are often used to refer to quarters of the year;
19-
// mark them up only in the {Q1} format.
20-
if ($params['type'] == 'ref') {
21-
if ($params['id'] <= 4) {
22-
return false;
23-
}
24-
}
25-
26-
return true;
27-
}
28-
2917
}

src/docs/user/userguide/remarkup.diviner

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ Markdown-style links are also supported:
297297

298298
= Linking to Objects =
299299

300-
You can link to Differential revisions, Diffusion commits and Maniphest tasks
301-
by mentioning the name of an object:
300+
You can link to Phabricator objects, such as Differential revisions, Diffusion
301+
commits and Maniphest tasks, by mentioning the name of an object:
302302

303303
D123 # Link to Differential revision D123
304304
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:
310310

311311
T123#4 # Link to comment #4 of T123
312312

313+
See the Phabricator configuraton setting `remarkup.ignored-object-names` to
314+
modify this behavior.
315+
313316
= Embedding Objects
314317

315318
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:
411414
and have them render inline.
412415

413416
This option is disabled by default because it has security and/or
414-
silliness implications. Read the description in `default.conf.php` before
415-
enabling it.
417+
silliness implications. Carefully read the description before enabling it.
416418

417419
= Image Macros =
418420

src/infrastructure/markup/rule/PhabricatorObjectRemarkupRule.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ private function markupObject(array $params) {
158158
return $params['original'];
159159
}
160160

161+
$regex = trim(
162+
PhabricatorEnv::getEnvConfig('remarkup.ignored-object-names'));
163+
if ($regex && preg_match($regex, $params['original'])) {
164+
return $params['original'];
165+
}
166+
161167
$engine = $this->getEngine();
162168
$token = $engine->storeText('x');
163169

0 commit comments

Comments
 (0)