@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix parsing of anchors in Phriction document link syntax

Summary: Ref T4280. At some point (probably D15732) we started getting anchor parsing wrong. Just pop the anchor off before doing all the logic, then put it back on at the end.

Test Plan:
Tested various forms like:

```
[[ x ]]
[[ x | z ]]
[[ x#y | z ]]
[[ ./x#y | z ]]
```

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T4280

Differential Revision: https://secure.phabricator.com/D16083

+18 -8
+17 -7
src/applications/phriction/markup/PhrictionRemarkupRule.php
··· 16 16 } 17 17 18 18 public function markupDocumentLink(array $matches) { 19 - $link = trim($matches[1]); 19 + // If the link contains an anchor, separate that off first. 20 + $parts = explode('#', trim($matches[1]), 2); 21 + if (count($parts) == 2) { 22 + $link = $parts[0]; 23 + $anchor = $parts[1]; 24 + } else { 25 + $link = $parts[0]; 26 + $anchor = null; 27 + } 20 28 21 29 // Handle relative links. 22 30 if ((substr($link, 0, 2) === './') || (substr($link, 0, 3) === '../')) { ··· 67 75 $metadata[] = array( 68 76 'token' => $token, 69 77 'link' => $link, 78 + 'anchor' => $anchor, 70 79 'explicitName' => $name, 71 80 ); 72 81 $engine->setTextMetadata(self::KEY_RULE_PHRICTION_LINK, $metadata); ··· 140 149 } 141 150 } 142 151 143 - $uri = new PhutilURI($link); 144 - $slug = $uri->getPath(); 145 - $fragment = $uri->getFragment(); 146 - $slug = PhabricatorSlug::normalize($slug); 147 - $slug = PhrictionDocument::getSlugURI($slug); 148 - $href = (string)id(new PhutilURI($slug))->setFragment($fragment); 152 + $uri = new PhutilURI($link); 153 + $slug = $uri->getPath(); 154 + $slug = PhabricatorSlug::normalize($slug); 155 + $slug = PhrictionDocument::getSlugURI($slug); 156 + 157 + $anchor = idx($spec, 'anchor'); 158 + $href = (string)id(new PhutilURI($slug))->setFragment($anchor); 149 159 150 160 $text_mode = $this->getEngine()->isTextMode(); 151 161 $mail_mode = $this->getEngine()->isHTMLMailMode();
+1 -1
src/infrastructure/markup/PhabricatorMarkupEngine.php
··· 42 42 private $objects = array(); 43 43 private $viewer; 44 44 private $contextObject; 45 - private $version = 15; 45 + private $version = 16; 46 46 private $engineCaches = array(); 47 47 private $auxiliaryConfig = array(); 48 48