Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14325676
D16908.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D16908.diff
View Options
diff --git a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
--- a/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
+++ b/src/applications/diffusion/application/PhabricatorDiffusionApplication.php
@@ -101,7 +101,7 @@
')(?P<commit>[a-f0-9]+)'
=> 'DiffusionCommitController',
- '/source/(?P<repositoryShortName>[^/.]+)(?P<dotgit>\.git)?'
+ '/source/(?P<repositoryShortName>[^/]+)'
=> $repository_routes,
'/diffusion/' => array(
diff --git a/src/applications/diffusion/controller/DiffusionController.php b/src/applications/diffusion/controller/DiffusionController.php
--- a/src/applications/diffusion/controller/DiffusionController.php
+++ b/src/applications/diffusion/controller/DiffusionController.php
@@ -92,6 +92,8 @@
$short_name = $request->getURIData('repositoryShortName');
if (strlen($short_name)) {
+ // If the short name ends in ".git", ignore it.
+ $short_name = preg_replace('/\\.git\z/', '', $short_name);
return $short_name;
}
diff --git a/src/applications/diffusion/controller/DiffusionServeController.php b/src/applications/diffusion/controller/DiffusionServeController.php
--- a/src/applications/diffusion/controller/DiffusionServeController.php
+++ b/src/applications/diffusion/controller/DiffusionServeController.php
@@ -88,13 +88,6 @@
}
}
- // If the request was for a path like "/source/libphutil.git" but the
- // repository is not a Git repository, reject the request.
- $type_git = PhabricatorRepositoryType::REPOSITORY_TYPE_GIT;
- if ($request->getURIData('dotgit') && ($vcs !== $type_git)) {
- return null;
- }
-
return $vcs;
}
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -442,6 +442,15 @@
'short names may not contain only numbers.',
$slug));
}
+
+ if (preg_match('/\\.git/', $slug)) {
+ throw new Exception(
+ pht(
+ 'The name "%s" is not a valid repository short name. Repository '.
+ 'short names must not end in ".git". This suffix will be added '.
+ 'automatically in appropriate contexts.',
+ $slug));
+ }
}
public static function assertValidCallsign($callsign) {
@@ -592,21 +601,12 @@
}
public static function parseRepositoryServicePath($request_path, $vcs) {
-
- // NOTE: In Mercurial over SSH, the path will begin without a leading "/",
- // so we're matching it optionally.
-
- if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) {
- $maybe_git = '(?:\\.git)?';
- } else {
- $maybe_git = null;
- }
+ $is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT);
$patterns = array(
'(^'.
- '(?P<base>/?(?:diffusion|source)/(?P<identifier>[^/.]+))'.
- $maybe_git.
- '(?P<path>(?:/|.*)?)'.
+ '(?P<base>/?(?:diffusion|source)/(?P<identifier>[^/]+))'.
+ '(?P<path>.*)'.
'\z)',
);
@@ -618,6 +618,10 @@
}
$identifier = $matches['identifier'];
+ if ($is_git) {
+ $identifier = preg_replace('/\\.git\z/', '', $identifier);
+ }
+
$base = $matches['base'];
$path = $matches['path'];
break;
diff --git a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
--- a/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
+++ b/src/applications/repository/storage/__tests__/PhabricatorRepositoryTestCase.php
@@ -190,6 +190,9 @@
'-ated',
'_underscores_',
'yes!',
+ 'quack.git',
+ 'git.git',
+ '.git.git.git',
// 65-character names are no good.
str_repeat('a', 65),
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 2:14 PM (6 h, 55 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6904869
Default Alt Text
D16908.diff (4 KB)
Attached To
Mode
D16908: Don't let users pick "whatever.git" as a repository short name, make "." work
Attached
Detach File
Event Timeline
Log In to Comment