Skip to content

Commit 5e1711f

Browse files
committed
fix header isValidKeyName #374
1 parent dd4b3d3 commit 5e1711f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Qiniu/Http/Header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function count()
264264
*/
265265
private static function isValidKeyName($str)
266266
{
267-
for ($i = 0; $i < count($str); $i += 1) {
267+
for ($i = 0; $i < strlen($str); $i += 1) {
268268
if (!isset(self::$isTokenTable[$str[$i]])) {
269269
return false;
270270
}

tests/Qiniu/Tests/HeaderTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ public function testNormalizeKey()
4040
$this->assertEquals($actual, $except);
4141
}
4242

43+
44+
public function testInvalidKeyName()
45+
{
46+
$except = array(
47+
'a:x-test-1',
48+
);
49+
50+
$actual = array_map(function ($str) {
51+
return Header::normalizeKey($str);
52+
}, $except);
53+
54+
$this->assertEquals($except, $actual);
55+
}
56+
4357
public function testGetRawData()
4458
{
4559
$header = new Header($this->heads);

0 commit comments

Comments
 (0)