Fix an issue with tail parsing in object embeds in remarkup
Summary:
Fixes T6619. In `{Xnnn key=value, key=value}` we did not require a separator between the object and the key-value part. This could lead to `{rX11aaa}` being parsed as `{rX11 aaa}`, i.e. a reference to `rX11` with parameter `aaa` set.
Instead, require a space or comma before we'll parse key-value parts of embedded objects.
Test Plan:
Added and executed unit tests.
{F242002}
Reviewers: chad, btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T6619
Differential Revision: https://secure.phabricator.com/D10915
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
final class DiffusionCommitRemarkupRuleTestCase extends PhabricatorTestCase {
|
||||
|
||||
public function testProjectObjectRemarkup() {
|
||||
$cases = array(
|
||||
'{rP12f3f6d3a9ef9c7731051815846810cb3c4cd248}' => array(
|
||||
'embed' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP12f3f6d3a9ef9c7731051815846810cb3c4cd248',
|
||||
),
|
||||
),
|
||||
'ref' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP12f3f6d3a9ef9c7731051815846810cb3c4cd248',
|
||||
),
|
||||
),
|
||||
),
|
||||
'{rP1234, key=value}' => array(
|
||||
'embed' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP1234',
|
||||
'tail' => ', key=value',
|
||||
),
|
||||
),
|
||||
'ref' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP1234',
|
||||
),
|
||||
),
|
||||
),
|
||||
'{rP1234 key=value}' => array(
|
||||
'embed' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP1234',
|
||||
'tail' => ' key=value',
|
||||
),
|
||||
),
|
||||
'ref' => array(
|
||||
array(
|
||||
'offset' => 1,
|
||||
'id' => 'rP1234',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
foreach ($cases as $input => $expect) {
|
||||
$rule = new DiffusionCommitRemarkupRule();
|
||||
$matches = $rule->extractReferences($input);
|
||||
$this->assertEqual($expect, $matches, $input);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user