Skip to content

Commit

Permalink
Don't fatal when encountering [[ <bad URI > | ... ]]
Browse files Browse the repository at this point in the history
Summary:
Fixes T12796. In D17647, the parser became more strict, but this remarkup rule doesn't deal with it gracefully.

Instead, detect when the parse failed and bail out.

Test Plan:
  - Put `[[ http://good.com#u:p@evil.com/ | broken ]]` into a Remarkup document without backticks.
  - Before patch: fatal ("rejecting ambiguous URI").
  - After patch: link doesn't work (which is correct), but page does.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12796

Differential Revision: https://secure.phabricator.com/D18076
  • Loading branch information
epriestley committed Jun 5, 2017
1 parent a900d7b commit 74a1350
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -120,9 +120,16 @@ public function markupDocumentLink(array $matches) {
$protocols = $this->getEngine()->getConfig(
'uri.allowed-protocols',
array());
$protocol = id(new PhutilURI($uri))->getProtocol();
if (!idx($protocols, $protocol)) {
// Don't treat this as a URI if it's not an allowed protocol.

try {
$protocol = id(new PhutilURI($uri))->getProtocol();
if (!idx($protocols, $protocol)) {
// Don't treat this as a URI if it's not an allowed protocol.
$is_uri = false;
}
} catch (Exception $ex) {
// We can end up here if we try to parse an ambiguous URI, see
// T12796.
$is_uri = false;
}
}
Expand Down

0 comments on commit 74a1350

Please sign in to comment.