Skip to content

Commit

Permalink
Merge pull request #375 from qiniu/hotfix/header-key-name-valid
Browse files Browse the repository at this point in the history
fix header isValidKeyName
  • Loading branch information
xwen-winnie committed Jan 25, 2022
2 parents dd4b3d3 + 5e1711f commit 5221503
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Qiniu/Http/Header.php
Expand Up @@ -264,7 +264,7 @@ public function count()
*/
private static function isValidKeyName($str)
{
for ($i = 0; $i < count($str); $i += 1) {
for ($i = 0; $i < strlen($str); $i += 1) {
if (!isset(self::$isTokenTable[$str[$i]])) {
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions tests/Qiniu/Tests/HeaderTest.php
Expand Up @@ -40,6 +40,20 @@ public function testNormalizeKey()
$this->assertEquals($actual, $except);
}


public function testInvalidKeyName()
{
$except = array(
'a:x-test-1',
);

$actual = array_map(function ($str) {
return Header::normalizeKey($str);
}, $except);

$this->assertEquals($except, $actual);
}

public function testGetRawData()
{
$header = new Header($this->heads);
Expand Down

0 comments on commit 5221503

Please sign in to comment.