Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15398591
D16103.id38742.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
D16103.id38742.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
@@ -61,7 +61,7 @@
$host = '(?P<host>[^/:]+)';
$path = ':(?P<path>.*)';
- $ok = preg_match('(^\s*'.$user.$host.$path.'\z)', $uri, $matches);
+ $ok = preg_match('(^'.$user.$host.$path.'\z)', $uri, $matches);
if (!$ok) {
throw new Exception(
pht(
@@ -344,6 +344,12 @@
$head = $matches['head'];
$last = $matches['last'];
+ // If any part of this has spaces in it, it's not a Git URI. We fail here
+ // so we fall back and don't fail more abruptly later.
+ if (preg_match('(\s)', $head.$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
@@ -151,6 +151,10 @@
'x' => '/',
),
$uri->getQueryParams());
+
+ // This is not a legitimate URI and should not parse as one.
+ $uri = new PhutilURI('fruit.list: apple banana cherry');
+ $this->assertEqual('', $uri->getDomain());
}
public function testAmbiguousURIs() {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mar 18 2025, 12:46 AM (5 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7707417
Default Alt Text
D16103.id38742.diff (1 KB)
Attached To
Mode
D16103: Don't detect long sentences which happen to have a colon in them as Git URIs
Attached
Detach File
Event Timeline
Log In to Comment