Skip to content

Commit

Permalink
Default to an empty string when validating the signature hash query p…
Browse files Browse the repository at this point in the history
…arameter (#23721)
  • Loading branch information
hmazter authored and taylorotwell committed Mar 28, 2018
1 parent 13f732e commit 30d2f7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 30d2f7f

Please sign in to comment.