From 34c488e1651ee34edabd3af4231fef385d52b7d5 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Apr 2016 19:04:22 -0700 Subject: [PATCH] Normalize Phriction links when looking them up in remarkup Summary: Fixes T10845. Test Plan: Verified that `[[ quack ]]` and `[[ QUACK ]]` both work. Previously, the link had to exactly match the capitalization of the target. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10845 Differential Revision: https://secure.phabricator.com/D15777 --- .../phriction/markup/PhrictionRemarkupRule.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/applications/phriction/markup/PhrictionRemarkupRule.php b/src/applications/phriction/markup/PhrictionRemarkupRule.php index 5f5a91a280..79e3788d11 100644 --- a/src/applications/phriction/markup/PhrictionRemarkupRule.php +++ b/src/applications/phriction/markup/PhrictionRemarkupRule.php @@ -104,6 +104,7 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { foreach ($metadata as $spec) { $link = $spec['link']; + $slug = PhabricatorSlug::normalize($link); $name = $spec['explicitName']; $class = 'phriction-link'; @@ -111,24 +112,24 @@ final class PhrictionRemarkupRule extends PhutilRemarkupRule { // in text as: "Title" . Otherwise, we'll just render: . $is_interesting_name = (bool)strlen($name); - if (idx($existant_documents, $link) === null) { + if (idx($existant_documents, $slug) === null) { // The target document doesn't exist. if ($name === null) { - $name = explode('/', trim($link, '/')); + $name = explode('/', trim($slug, '/')); $name = end($name); } $class = 'phriction-link-missing'; - } else if (idx($visible_documents, $link) === null) { + } else if (idx($visible_documents, $slug) === null) { // The document exists, but the user can't see it. if ($name === null) { - $name = explode('/', trim($link, '/')); + $name = explode('/', trim($slug, '/')); $name = end($name); } $class = 'phriction-link-lock'; } else { if ($name === null) { // Use the title of the document if no name is set. - $name = $visible_documents[$link] + $name = $visible_documents[$slug] ->getContent() ->getTitle();