Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14019682
D16187.id38942.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D16187.id38942.diff
View Options
diff --git a/src/parser/PhutilURI.php b/src/parser/PhutilURI.php
--- a/src/parser/PhutilURI.php
+++ b/src/parser/PhutilURI.php
@@ -350,6 +350,13 @@
return false;
}
+ // If the second part only contains digits, assume we're looking at
+ // casually specified "domain.com:123" URI, not a Git URI pointed at an
+ // entirely numeric relative path.
+ if (preg_match('(^\d+\z)', $last)) {
+ return false;
+ }
+
// If the first part has a "." or an "@" in it, interpret it as a domain
// or a "user@host" string.
if (preg_match('([.@])', $head)) {
diff --git a/src/parser/__tests__/PhutilURITestCase.php b/src/parser/__tests__/PhutilURITestCase.php
--- a/src/parser/__tests__/PhutilURITestCase.php
+++ b/src/parser/__tests__/PhutilURITestCase.php
@@ -177,6 +177,14 @@
$uri = new PhutilURI('user@localhost:todo.txt');
$this->assertEqual('localhost', $uri->getDomain());
+
+ // This could either be a Git URI with relative path "22", or a normal URI
+ // with port "22". We should assume it is a port number because this is
+ // relatively common, while relative Git URIs pointing at numeric filenames
+ // are bizarre.
+ $uri = new PhutilURI('domain.com:22');
+ $this->assertEqual('domain.com', $uri->getDomain());
+ $this->assertEqual('22', $uri->getPort());
}
public function testDefaultPorts() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 6, 11:23 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6742370
Default Alt Text
D16187.id38942.diff (1 KB)
Attached To
Mode
D16187: Disambiguate "host.com:123" as a port, not a relative path
Attached
Detach File
Event Timeline
Log In to Comment