mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 06:42:42 +01:00
isSelfURI: fix anchors and relative URIs (that are "self" indeed)
Summary: Example cases that were wrongly considered external URLs: - "#foo" - "/foo" Note that Phorge usually does not change stable things. In fact this thing was not documented even inline, and was not even in the unit tests. So this is a fix, and not a breaking change. Probably no one had ever tried it. Closes T15182 Test Plan: The already existing unit tests still work. The added ones make sense. There are no problems doing other random things. Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15182 Differential Revision: https://we.phorge.it/D25555
This commit is contained in:
parent
8fe3d68577
commit
328aee033f
2 changed files with 7 additions and 1 deletions
2
src/infrastructure/env/PhabricatorEnv.php
vendored
2
src/infrastructure/env/PhabricatorEnv.php
vendored
|
@ -433,7 +433,7 @@ final class PhabricatorEnv extends Phobject {
|
||||||
|
|
||||||
$host = $uri->getDomain();
|
$host = $uri->getDomain();
|
||||||
if (!phutil_nonempty_string($host)) {
|
if (!phutil_nonempty_string($host)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$host = phutil_utf8_strtolower($host);
|
$host = phutil_utf8_strtolower($host);
|
||||||
|
|
|
@ -243,6 +243,12 @@ final class PhabricatorEnvTestCase extends PhabricatorTestCase {
|
||||||
'https://old.example.com/path/to/resource.png' => true,
|
'https://old.example.com/path/to/resource.png' => true,
|
||||||
|
|
||||||
'https://other.example.com/' => false,
|
'https://other.example.com/' => false,
|
||||||
|
|
||||||
|
'/' => true,
|
||||||
|
'/self' => true,
|
||||||
|
'#self' => true,
|
||||||
|
'/#self' => true,
|
||||||
|
'/self/#self' => true,
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($map as $input => $expect) {
|
foreach ($map as $input => $expect) {
|
||||||
|
|
Loading…
Reference in a new issue