Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15309843
D16966.id40829.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D16966.id40829.diff
View Options
diff --git a/src/aphront/AphrontRequest.php b/src/aphront/AphrontRequest.php
--- a/src/aphront/AphrontRequest.php
+++ b/src/aphront/AphrontRequest.php
@@ -545,6 +545,13 @@
return id(new PhutilURI($path))->setQueryParams($get);
}
+ public function getAbsoluteRequestURI() {
+ $uri = $this->getRequestURI();
+ $uri->setDomain($this->getHost());
+ $uri->setProtocol($this->isHTTPS() ? 'https' : 'http');
+ return $uri;
+ }
+
public function isDialogFormPost() {
return $this->isFormPost() && $this->getStr('__dialog__');
}
diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php
--- a/src/aphront/configuration/AphrontApplicationConfiguration.php
+++ b/src/aphront/configuration/AphrontApplicationConfiguration.php
@@ -409,19 +409,25 @@
if (!preg_match('@/$@', $path) && $request->isHTTPGet()) {
$result = $this->routePath($maps, $path.'/');
if ($result) {
- $slash_uri = $request->getRequestURI()->setPath($path.'/');
+ $target_uri = $request->getAbsoluteRequestURI();
// We need to restore URI encoding because the webserver has
// interpreted it. For example, this allows us to redirect a path
// like `/tag/aa%20bb` to `/tag/aa%20bb/`, which may eventually be
// resolved meaningfully by an application.
- $slash_uri = phutil_escape_uri($slash_uri);
+ $target_path = phutil_escape_uri($path.'/');
+ $target_uri->setPath($target_path);
+ $target_uri = (string)$target_uri;
- $external = strlen($request->getRequestURI()->getDomain());
- return $this->buildRedirectController($slash_uri, $external);
+ return $this->buildRedirectController($target_uri, true);
}
}
+ $result = $site->new404Controller($request);
+ if ($result) {
+ return array($result, array());
+ }
+
return $this->build404Controller();
}
diff --git a/src/aphront/site/AphrontSite.php b/src/aphront/site/AphrontSite.php
--- a/src/aphront/site/AphrontSite.php
+++ b/src/aphront/site/AphrontSite.php
@@ -9,6 +9,10 @@
abstract public function newSiteForRequest(AphrontRequest $request);
abstract public function getRoutingMaps();
+ public function new404Controller(AphrontRequest $request) {
+ return null;
+ }
+
protected function isHostMatch($host, array $uris) {
foreach ($uris as $uri) {
if (!strlen($uri)) {
diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php
--- a/src/applications/phame/application/PhabricatorPhameApplication.php
+++ b/src/applications/phame/application/PhabricatorPhameApplication.php
@@ -92,7 +92,6 @@
'/' => array(
'' => 'PhameBlogViewController',
'post/(?P<id>\d+)/(?:(?P<slug>[^/]+)/)?' => 'PhamePostViewController',
- '.*' => 'PhameBlog404Controller',
),
);
diff --git a/src/applications/phame/site/PhameBlogSite.php b/src/applications/phame/site/PhameBlogSite.php
--- a/src/applications/phame/site/PhameBlogSite.php
+++ b/src/applications/phame/site/PhameBlogSite.php
@@ -60,6 +60,10 @@
return id(new PhameBlogSite())->setBlog($blog);
}
+ public function new404Controller(AphrontRequest $request) {
+ return new PhameBlog404Controller();
+ }
+
public function getRoutingMaps() {
$app = PhabricatorApplication::getByClass('PhabricatorPhameApplication');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 7, 7:46 AM (8 h, 26 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7327352
Default Alt Text
D16966.id40829.diff (3 KB)
Attached To
Mode
D16966: Allow custom Sites to have custom 404 controllers
Attached
Detach File
Event Timeline
Log In to Comment