Skip to content
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

[5.6] Default to an empty string when validating the signature hash query parameter #23721

Merged
merged 1 commit into from
Mar 28, 2018
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
2 changes: 1 addition & 1 deletion src/Illuminate/Routing/UrlGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ public function hasValidSignature(Request $request)

$signature = hash_hmac('sha256', $original, call_user_func($this->keyResolver));

return hash_equals($signature, $request->query('signature')) &&
return hash_equals($signature, $request->query('signature', '')) &&
! ($expires && Carbon::now()->getTimestamp() > $expires);
}

Expand Down
9 changes: 9 additions & 0 deletions tests/Integration/Routing/UrlSigningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public function test_temporary_signed_urls()
$this->assertEquals('invalid', $this->get($url)->original);
}

public function test_signed_url_with_url_without_signature_parameter()
{
Route::get('/foo/{id}', function (Request $request, $id) {
return $request->hasValidSignature() ? 'valid' : 'invalid';
})->name('foo');

$this->assertEquals('invalid', $this->get('/foo/1')->original);
}

public function test_signed_middleware()
{
Route::get('/foo/{id}', function (Request $request, $id) {
Expand Down