Page MenuHomePhabricator

Preserve nonstandard ports during 404 redirects which add "/" to the ends of URIs
ClosedPublic

Authored by epriestley on Jan 3 2017, 5:54 PM.
Tags
None
Referenced Files
F15486769: D17134.diff
Thu, Apr 10, 9:33 AM
F15446869: D17134.diff
Thu, Mar 27, 8:35 PM
F15414923: D17134.id41209.diff
Mar 20 2025, 3:09 AM
F15404378: D17134.id.diff
Mar 18 2025, 7:25 AM
F15395722: D17134.id41203.diff
Mar 16 2025, 9:16 AM
Unknown Object (File)
Feb 21 2025, 3:00 PM
Unknown Object (File)
Feb 20 2025, 1:50 PM
Unknown Object (File)
Feb 11 2025, 6:45 AM
Subscribers
None

Details

Summary

Fixes T12058. When the user visits /maniphest, for example, we redirect to /maniphest/.

Since this redirect is very low-level (at the Aphront level, below the Site level) we need to preserve the request Host rather than correct it to PhabricatorEnv::getURI() or similar -- the request may be hiting a different Site like a blog domain.

Currently, we do not preserve the port. Instead, preserve the port if it is not a standard port for the protocol (80 for http, 443 for https).

Test Plan
  • Made a request with a missing slash and a normal port in my browser, got redirected normally.
  • Made a request with a missing slash and a nonstandard port, got redirected on the same port.
$ curl -H 'Host: local.phacility.com:123' -v http://local.phacility.com/diffusion
*   Trying 127.0.0.1...
* Connected to local.phacility.com (127.0.0.1) port 80 (#0)
> GET /diffusion HTTP/1.1
...
> 
< HTTP/1.1 302 Found
...
< Location: http://local.phacility.com:123/diffusion/
...

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable