From 5b1d73e5ddaad42eed094dc5a3e8d439fa492e5b Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Mon, 5 Nov 2012 15:47:51 -0800 Subject: [PATCH] make remarkup savvier about fragments in phriction links Summary: use PhutilURI class to get the slug and the fragment, normalize the slug, and then glue it back together with another PhutilURI fixes https://github.com/facebook/phabricator/issues/228 Test Plan: had a few links like [[ example/doc#title | wiki fun ]] and verified links generated were correct Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin Differential Revision: https://secure.phabricator.com/D3894 --- .../rule/PhabricatorRemarkupRulePhriction.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php b/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php index ea7270dae2..aa31911cfd 100644 --- a/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php +++ b/src/infrastructure/markup/rule/PhabricatorRemarkupRulePhriction.php @@ -15,19 +15,23 @@ final class PhabricatorRemarkupRulePhriction public function markupDocumentLink($matches) { - $slug = trim($matches[1]); - $name = trim(idx($matches, 2, $slug)); + $link = trim($matches[1]); + $name = trim(idx($matches, 2, $link)); $name = explode('/', trim($name, '/')); $name = end($name); - $slug = PhabricatorSlug::normalize($slug); - $uri = PhrictionDocument::getSlugURI($slug); + $uri = new PhutilURI($link); + $slug = $uri->getPath(); + $fragment = $uri->getFragment(); + $slug = PhabricatorSlug::normalize($slug); + $slug = PhrictionDocument::getSlugURI($slug); + $href = (string) id(new PhutilURI($slug))->setFragment($fragment); return $this->getEngine()->storeText( phutil_render_tag( 'a', array( - 'href' => $uri, + 'href' => $href, 'class' => 'phriction-link', ), phutil_escape_html($name)));