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
F19263906: D17134.id41203.diff
Mon, Dec 22, 6:34 PM
F19180133: D17134.diff
Tue, Dec 16, 2:10 AM
F18921581: D17134.id41209.diff
Nov 9 2025, 2:17 PM
F18833668: D17134.diff
Oct 26 2025, 5:06 AM
F18782951: D17134.id41209.diff
Oct 13 2025, 3:05 AM
F18622704: D17134.diff
Sep 15 2025, 12:43 PM
F18086815: D17134.id.diff
Aug 6 2025, 12:17 AM
F18086722: D17134.id.diff
Aug 5 2025, 11:43 PM
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
Branch
redirect1
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 15088
Build 19804: Run Core Tests
Build 19803: arc lint + arc unit