From f391364bb74d50d8c3e58b9ec8fd016ee4535f4c Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 3 Mar 2015 10:39:52 -0800 Subject: [PATCH] Don't match parentheses as a hashtag character Summary: Fixes T6818. Test Plan: Added and ran unit tests. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T6818 Differential Revision: https://secure.phabricator.com/D11954 --- .../project/remarkup/ProjectRemarkupRule.php | 2 +- .../__tests__/ProjectRemarkupRuleTestCase.php | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/applications/project/remarkup/ProjectRemarkupRule.php b/src/applications/project/remarkup/ProjectRemarkupRule.php index 2f93a88e95..ca11a7ea8c 100644 --- a/src/applications/project/remarkup/ProjectRemarkupRule.php +++ b/src/applications/project/remarkup/ProjectRemarkupRule.php @@ -30,7 +30,7 @@ final class ProjectRemarkupRule extends PhabricatorObjectRemarkupRule { // In other contexts, the PhabricatorProjectProjectPHIDType pattern is // controlling and these names should parse correctly. - return '[^\s.\d!,:;{}#]+(?:[^\s!,:;{}#][^\s.!,:;{}#]+)*'; + return '[^\s.\d!,:;{}#\(\)]+(?:[^\s!,:;{}#\(\)][^\s.!,:;{}#\(\)]+)*'; } protected function loadObjects(array $ids) { diff --git a/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php b/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php index 4e72514b26..4efc98a5b8 100644 --- a/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php +++ b/src/applications/project/remarkup/__tests__/ProjectRemarkupRuleTestCase.php @@ -45,6 +45,31 @@ final class ProjectRemarkupRuleTestCase extends PhabricatorTestCase { ), ), ), + + // Don't match a terminal parenthesis. This fixes these constructs in + // natural language. + 'There is some documentation (see #guides).' => array( + 'embed' => array(), + 'ref' => array( + array( + 'offset' => 34, + 'id' => 'guides', + ), + ), + ), + + // Don't match internal parentheses either. This makes the terminal + // parenthesis behavior less arbitrary (otherwise, we match open + // parentheses but not closing parentheses, which is surprising). + '#a(b)c' => array( + 'embed' => array(), + 'ref' => array( + array( + 'offset' => 1, + 'id' => 'a', + ), + ), + ), ); foreach ($cases as $input => $expect) {