Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BrowserKit] Allow Referer set by history to be overridden #36592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[BrowserKit] Allow Referer set by history to be overridden (3.4)
  • Loading branch information
Slamdunk committed Apr 27, 2020
commit 4774946fbd6a6d5890b9c2dbc933865bdd532045
2 changes: 1 addition & 1 deletion 2 src/Symfony/Component/BrowserKit/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function request($method, $uri, array $parameters = [], array $files = []
$uri = preg_replace('{^'.parse_url($uri, PHP_URL_SCHEME).'}', $server['HTTPS'] ? 'https' : 'http', $uri);
}

if (!$this->history->isEmpty()) {
if (!isset($server['HTTP_REFERER']) && !$this->history->isEmpty()) {
$server['HTTP_REFERER'] = $this->history->current()->getUri();
}

Expand Down
9 changes: 9 additions & 0 deletions 9 src/Symfony/Component/BrowserKit/Tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ public function testRequestReferer()
$this->assertEquals('http://www.example.com/foo/foobar', $server['HTTP_REFERER'], '->request() sets the referer');
}

public function testRequestRefererCanBeOverridden()
{
$client = new TestClient();
$client->request('GET', 'http://www.example.com/foo/foobar');
$client->request('GET', 'bar', [], [], ['HTTP_REFERER' => 'xyz']);
$server = $client->getRequest()->getServer();
$this->assertEquals('xyz', $server['HTTP_REFERER'], '->request() allows referer to be overridden');
}

public function testRequestHistory()
{
$client = new TestClient();
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.