@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorMacroTestCase
4 extends PhabricatorTestCase {
5
6 public function testMacroNames() {
7 $lit = "\xF0\x9F\x94\xA5";
8 $combining_diaeresis = "\xCC\x88";
9
10 $cases = array(
11 // Only 2 glyphs long.
12 "u{$combining_diaeresis}n" => false,
13 "{$lit}{$lit}" => false,
14
15 // Too short.
16 'a' => false,
17 '' => false,
18
19 // Bad characters.
20 'yes!' => false,
21 "{$lit} {$lit} {$lit}" => false,
22 "aaa\nbbb" => false,
23 'aaa~' => false,
24 'aaa`' => false,
25
26 // Special rejections for only latin symbols.
27 '---' => false,
28 '___' => false,
29 '-_-' => false,
30 ':::' => false,
31 '-_:' => false,
32
33 "{$lit}{$lit}{$lit}" => true,
34 'bwahahaha' => true,
35 "u{$combining_diaeresis}nt" => true,
36 'a-a-a-a' => true,
37 );
38
39 foreach ($cases as $input => $expect) {
40 $this->assertEqual(
41 $expect,
42 PhabricatorMacroNameTransaction::isValidMacroName($input),
43 pht('Validity of macro "%s"', $input));
44 }
45 }
46}