Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2862987
D25847.1736457502.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
14 KB
Referenced Files
None
Subscribers
None
D25847.1736457502.diff
View Options
diff --git a/src/infrastructure/env/PhabricatorEnv.php b/src/infrastructure/env/PhabricatorEnv.php
--- a/src/infrastructure/env/PhabricatorEnv.php
+++ b/src/infrastructure/env/PhabricatorEnv.php
@@ -11,7 +11,7 @@
* The primary role of this class is to provide an API for reading
* Phabricator configuration, @{method:getEnvConfig}:
*
- * $value = PhabricatorEnv::getEnvConfig('some.key', $default);
+ * $value = PhabricatorEnv::getEnvConfig('some.key');
*
* The class also handles some URI construction based on configuration, via
* the methods @{method:getURI}, @{method:getProductionURI},
@@ -431,8 +431,11 @@
public static function isSelfURI($raw_uri) {
$uri = new PhutilURI($raw_uri);
+ // Relative paths always are self-URIs.
$host = $uri->getDomain();
- if (!phutil_nonempty_string($host)) {
+ $prot = $uri->getProtocol();
+ if (!phutil_nonempty_string($host) &&
+ !phutil_nonempty_string($prot)) {
return true;
}
diff --git a/src/infrastructure/markup/remarkup/__tests__/PhutilRemarkupEngineTestCase.php b/src/infrastructure/markup/remarkup/__tests__/PhutilRemarkupEngineTestCase.php
--- a/src/infrastructure/markup/remarkup/__tests__/PhutilRemarkupEngineTestCase.php
+++ b/src/infrastructure/markup/remarkup/__tests__/PhutilRemarkupEngineTestCase.php
@@ -2,10 +2,12 @@
/**
* Test cases for @{class:PhutilRemarkupEngine}.
+ * This needs to be a PhabricatorTestCase since it may want
+ * to access some Phorge URI configurations.
* @TODO: This unit is not always triggered when you need it.
* https://we.phorge.it/T15500
*/
-final class PhutilRemarkupEngineTestCase extends PhutilTestCase {
+final class PhutilRemarkupEngineTestCase extends PhabricatorTestCase {
public function testEngine() {
$root = dirname(__FILE__).'/remarkup/';
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-brackets.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-brackets.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-brackets.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-brackets.txt
@@ -1,5 +1,5 @@
<http://www.zany.com/omg/weird_url,,,>
~~~~~~~~~~
-<p><a href="http://www.zany.com/omg/weird_url,,," class="remarkup-link" target="_blank" rel="noreferrer">http://www.zany.com/omg/weird_url,,,</a></p>
+<p><a href="http://www.zany.com/omg/weird_url,,," class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.zany.com/omg/weird_url,,,</a></p>
~~~~~~~~~~
http://www.zany.com/omg/weird_url,,,
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-edge-cases.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-edge-cases.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-edge-cases.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-edge-cases.txt
@@ -10,17 +10,17 @@
Quick! http://www.example.com/!
~~~~~~~~~~
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
-<p>(<a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>)</p>
+<p>(<a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>)</p>
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
-<p><a href="http://www.example.com/wiki/example_(disambiguation)" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/wiki/example_(disambiguation)</a></p>
+<p><a href="http://www.example.com/wiki/example_(disambiguation)" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/wiki/example_(disambiguation)</a></p>
-<p>(example <a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>)</p>
+<p>(example <a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>)</p>
-<p>Quick! <a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>!</p>
+<p>Quick! <a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>!</p>
~~~~~~~~~~
http://www.example.com/
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mailto.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mailto.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mailto.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mailto.txt
@@ -5,11 +5,11 @@
[[mailto:alincoln@example.com]]
~~~~~~~~~~
-<p><a href="mailto:alincoln@example.com" class="remarkup-link" target="_blank" rel="noreferrer">mail me</a></p>
+<p><a href="mailto:alincoln@example.com" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">mail me</a></p>
-<p><a href="mailto:alincoln@example.com" class="remarkup-link" target="_blank" rel="noreferrer">mail me</a></p>
+<p><a href="mailto:alincoln@example.com" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">mail me</a></p>
-<p><a href="mailto:alincoln@example.com" class="remarkup-link" target="_blank" rel="noreferrer">alincoln@example.com</a></p>
+<p><a href="mailto:alincoln@example.com" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">alincoln@example.com</a></p>
~~~~~~~~~~
mail me <alincoln@example.com>
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mixed.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mixed.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mixed.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-mixed.txt
@@ -5,11 +5,11 @@
<http://www.example.com/ [[http://www.example.net/ | Example]]>
~~~~~~~~~~
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">Example</a>(<a href="http://www.alternate.org/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.alternate.org/</a>)</p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">Example</a>(<a href="http://www.alternate.org/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.alternate.org/</a>)</p>
-<p>(<a href="http://www.alternate.org/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.alternate.org/</a>)<a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">Example</a></p>
+<p>(<a href="http://www.alternate.org/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.alternate.org/</a>)<a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">Example</a></p>
-<p><<a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a> <a href="http://www.example.net/" class="remarkup-link" target="_blank" rel="noreferrer">Example</a>></p>
+<p><<a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a> <a href="http://www.example.net/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">Example</a>></p>
~~~~~~~~~~
Example <http://www.example.com/>(http://www.alternate.org/)
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-noreferrer.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-noreferrer.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-noreferrer.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-noreferrer.txt
@@ -1,15 +1,24 @@
+I have no idea what should happen in this case.
+Technically it doesn't seem to be an external link.
+Browsers may make it external, though?
[[ /\evil.com ]]
[[ /
/evil.com ]]
~~~~~~~~~~
+<p>I have no idea what should happen in this case.
+Technically it doesn't seem to be an external link.
+Browsers may make it external, though?</p>
<p><a href="/\evil.com" class="remarkup-link" target="_blank" rel="noreferrer">/\evil.com</a></p>
<p><a href="/
/evil.com" class="remarkup-link" target="_blank" rel="noreferrer">/
/evil.com</a></p>
~~~~~~~~~~
+I have no idea what should happen in this case.
+Technically it doesn't seem to be an external link.
+Browsers may make it external, though?
/\evil.com
/
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-same-window.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-same-window.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-same-window.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-same-window.txt
@@ -2,9 +2,9 @@
http://www.example.com/
~~~~~~~~~~
-<p><a href="http://www.example.com/" class="remarkup-link" rel="noreferrer">http://www.example.com/</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" rel="noreferrer">http://www.example.com/</a></p>
-<p><a href="http://www.example.com/" class="remarkup-link" rel="noreferrer">http://www.example.com/</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" rel="noreferrer">http://www.example.com/</a></p>
~~~~~~~~~~
http://www.example.com/
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-square.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-square.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-square.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-square.txt
@@ -8,15 +8,15 @@
[[#anchor | Anchors ]]
~~~~~~~~~~
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a></p>
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">example.com</a></p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">example.com</a></p>
-<p><a href="http://www.example.com/x/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/x/</a></p>
+<p><a href="http://www.example.com/x/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/x/</a></p>
-<p><a href="http://www.example.com/page/#anchor" class="remarkup-link" rel="noreferrer">http://www.example.com/page/#anchor</a></p>
+<p><a href="http://www.example.com/page/#anchor" class="remarkup-link remarkup-link-ext" rel="noreferrer">http://www.example.com/page/#anchor</a></p>
-<p><a href="http://www.example.com/page/#anchor" class="remarkup-link" rel="noreferrer">Anchors</a></p>
+<p><a href="http://www.example.com/page/#anchor" class="remarkup-link remarkup-link-ext" rel="noreferrer">Anchors</a></p>
~~~~~~~~~~
http://www.example.com/
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-punctuation.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-punctuation.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-punctuation.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-punctuation.txt
@@ -2,8 +2,8 @@
http://www.example.com/..
http://www.example.com/!!!
~~~~~~~~~~
-<p><a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>,
-<a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>..
-<a href="http://www.example.com/" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/</a>!!!</p>
+<p><a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>,
+<a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>..
+<a href="http://www.example.com/" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/</a>!!!</p>
~~~~~~~~~~
http://www.example.com/, http://www.example.com/.. http://www.example.com/!!!
diff --git a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-tilde.txt b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-tilde.txt
--- a/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-tilde.txt
+++ b/src/infrastructure/markup/remarkup/__tests__/remarkup/link-with-tilde.txt
@@ -1,5 +1,5 @@
http://www.example.com/~~
~~~~~~~~~~
-<p><a href="http://www.example.com/~" class="remarkup-link" target="_blank" rel="noreferrer">http://www.example.com/~</a></p>
+<p><a href="http://www.example.com/~" class="remarkup-link remarkup-link-ext" target="_blank" rel="noreferrer">http://www.example.com/~</a></p>
~~~~~~~~~~
http://www.example.com/~~
diff --git a/src/infrastructure/parser/__tests__/PhutilURIHelperTestCase.php b/src/infrastructure/parser/__tests__/PhutilURIHelperTestCase.php
--- a/src/infrastructure/parser/__tests__/PhutilURIHelperTestCase.php
+++ b/src/infrastructure/parser/__tests__/PhutilURIHelperTestCase.php
@@ -4,6 +4,12 @@
public function testPhutilURIHelper() {
+ // Set a test environment.
+ // This is useful to don't rely on your local config.
+ $base = 'https://phorge.localhost';
+ $env = PhabricatorEnv::beginScopedEnv();
+ $env->overrideEnvConfig('phabricator.base-uri', $base);
+
// Every row is a test. Every column is:
// - 0: name of the test
// - 1: test input value
@@ -20,16 +26,13 @@
array('internal root dir', '/#asd', true, false, true),
array('external', 'https://gnu.org/', false, false, false),
array('external anchor', 'https://gnu.org/#asd', false, false, false),
+ array('external mail', 'mailto:info@wikipedia.org', false, false, false),
+ array('external mail', 'foo://whatever', false, false, false),
+ array('base uri', $base, true, false, false),
+ array('base uri anchor', "{$base}#asd", true, false, false),
+ array('base uri path', "$base/something", true, false, false),
);
- // Add additional self-tests if base URI is available.
- $base = PhabricatorEnv::getEnvConfigIfExists('phabricator.base-uri');
- if ($base) {
- $domain = id(new PhutilURI($base))->getDomain();
- $tests[] = array('base uri', $base, true, false, false);
- $tests[] = array('base uri anchor', "{$base}#asd", true, false, false);
- }
-
foreach ($tests as $test) {
$name = $test[0];
$uri = $test[1];
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 21:18 (5 d, 14 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1108773
Default Alt Text
D25847.1736457502.diff (14 KB)
Attached To
Mode
D25847: Fix regression in Remarkup unit tests and harden
Attached
Detach File
Event Timeline
Log In to Comment