Skip to content

Commit

Permalink
Merge branch '4.4'
Browse files Browse the repository at this point in the history
* 4.4: (53 commits)
  Fix Twig 1.x compatibility
  Deprecating templateExists method
  [Translator] Improve farsi(persian) translations for Form
  [Validator] Fix Changelog for #31511
  [Lock][Console] bump lock requirement in console
  [Lock] minor: add missing alias for PersistenStoreInterface
  Improve fa translations
  Dynamic bundle assets
  [Lock] rename and deprecate Factory into LockFactory
  [Debug] Restoring back the state of the Debug component (1st step)
  Spell "triggering" properly
  [Lock] Fix tests
  Added tests to cover the possibility of having scalars as services.
  fixed CS
  [Lock] Split \"StoreInterface\" into multiple interfaces with less responsability
  [VarDumper] Let browsers trigger their own search on double CMD/CTRL + F hit
  [Validator] Allow to use property paths to get limits in range constraint
  Fix missing deprecations
  fixed tests on old PHP versions
  [FrameworkBundle] Inform the user when save_path will be ignored
  ...
  • Loading branch information
nicolas-grekas committed Jul 11, 2019
2 parents bb90fb6 + cd214ce commit 6c3390a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ public function getPort()
$pos = strrpos($host, ':');
}

if (false !== $pos) {
return (int) substr($host, $pos + 1);
if (false !== $pos && $port = substr($host, $pos + 1)) {
return (int) $port;
}

return 'https' === $this->getScheme() ? 443 : 80;
Expand Down
12 changes: 12 additions & 0 deletions Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,18 @@ public function testTrustedPort()

$this->assertSame(443, $request->getPort());
}

public function testTrustedPortDoesNotDefaultToZero()
{
Request::setTrustedProxies(['1.1.1.1'], Request::HEADER_X_FORWARDED_ALL);

$request = Request::create('/');
$request->server->set('REMOTE_ADDR', '1.1.1.1');
$request->headers->set('X-Forwarded-Host', 'test.example.com');
$request->headers->set('X-Forwarded-Port', '');

$this->assertSame(80, $request->getPort());
}
}

class RequestContentProxy extends Request
Expand Down
2 changes: 1 addition & 1 deletion UrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ final class UrlHelper
private $requestStack;
private $requestContext;

public function __construct(RequestStack $requestStack, ?RequestContext $requestContext = null)
public function __construct(RequestStack $requestStack, RequestContext $requestContext = null)
{
$this->requestStack = $requestStack;
$this->requestContext = $requestContext;
Expand Down

0 comments on commit 6c3390a

Please sign in to comment.