-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #885 from biigle/patch-1
Check encoding of email string for API requests
- Loading branch information
Showing
2 changed files
with
24 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,6 +92,25 @@ public function testEmailCaseInsensitive() | |
$response->assertStatus(200); | ||
} | ||
|
||
public function testEmailEncoding() | ||
{ | ||
$token = ApiTokenTest::create([ | ||
// 'test_token', hashed with 4 rounds as defined in phpunit.xml | ||
'hash' => '$2y$04$9Ncj6qJVqenJ13VtdtV5yOca8rQyN1UwATdGpAQ80FeRjS67.Efaq', | ||
]); | ||
|
||
$token->owner->email = '[email protected]'; | ||
$token->owner->save(); | ||
|
||
// The request would produce a 500 error if the string was not escaped properly. | ||
// The string is from a real request that we observed. | ||
$response = $this->json('GET', '/api/v1/users', [], [ | ||
'PHP_AUTH_USER' => "\x81\x5C\x91\xE7=e\x17\xDD\x9Do\x19lgF", | ||
'PHP_AUTH_PW' => 'test_token', | ||
]); | ||
$response->assertStatus(401); | ||
} | ||
|
||
public function testTouchToken() | ||
{ | ||
$token = ApiTokenTest::create([ | ||
|