1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Tune project hashtags a little more

Summary: Fixes T7738. Improves handling of question marks and quotation marks.

Test Plan: Unit tests.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7738

Differential Revision: https://secure.phabricator.com/D12265
This commit is contained in:
epriestley 2015-04-03 16:38:19 -07:00
parent 7e0c516276
commit d8ab19a166
2 changed files with 45 additions and 1 deletions

View file

@ -30,7 +30,21 @@ final class ProjectRemarkupRule extends PhabricatorObjectRemarkupRule {
// In other contexts, the PhabricatorProjectProjectPHIDType pattern is // In other contexts, the PhabricatorProjectProjectPHIDType pattern is
// controlling and these names should parse correctly. // controlling and these names should parse correctly.
return '[^\s.\d!,:;{}#\(\)]+(?:[^\s!,:;{}#\(\)]*[^\s.!,:;{}#\(\)]+)*'; // These characters may never appear anywhere in a hashtag.
$never = '\s?!,:;{}#\\(\\)"\'';
// These characters may not appear at the beginning.
$never_first = '.\d';
// These characters may not appear at the end.
$never_last = '.';
return
'[^'.$never_first.$never.']+'.
'(?:'.
'[^'.$never.']*'.
'[^'.$never_last.$never.']+'.
')*';
} }
protected function loadObjects(array $ids) { protected function loadObjects(array $ids) {

View file

@ -81,6 +81,36 @@ final class ProjectRemarkupRuleTestCase extends PhabricatorTestCase {
), ),
), ),
'Is this #urgent?' => array(
'embed' => array(),
'ref' => array(
array(
'offset' => 9,
'id' => 'urgent',
),
),
),
'This is "#urgent".' => array(
'embed' => array(),
'ref' => array(
array(
'offset' => 10,
'id' => 'urgent',
),
),
),
'This is \'#urgent\'.' => array(
'embed' => array(),
'ref' => array(
array(
'offset' => 10,
'id' => 'urgent',
),
),
),
); );
foreach ($cases as $input => $expect) { foreach ($cases as $input => $expect) {