Skip to content

Commit f9ffb85

Browse files
authored
Merge pull request #321 from opentok/dev
Security Patch Update
2 parents 8d2da20 + 4d2b60d commit f9ffb85

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/OpenTok/Util/Validators.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,12 @@ public static function validateDTMFDigits(string $digits): void
423423
// Helpers
424424

425425
// credit: http://stackoverflow.com/a/173479
426-
protected static function isAssoc($arr)
426+
public static function isAssoc($arr): bool
427427
{
428+
if (array() === $arr) {
429+
return false;
430+
}
431+
428432
return array_keys($arr) !== range(0, count($arr) - 1);
429433
}
430434

tests/OpenTokTest/Validators/ValidatorsTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,30 @@ public function testWillPassCorrectPayload(): void
2323
Validators::validateForceMuteAllOptions($options);
2424
}
2525

26+
public function testIsAssocWithValidArray(): void
27+
{
28+
$haystack = [
29+
'one' => '1',
30+
'two' => '2',
31+
'three' => '3',
32+
'four' => '4'
33+
];
34+
35+
$this->assertTrue(Validators::isAssoc($haystack));
36+
}
37+
38+
public function testIsAssocWithInvalidArray(): void
39+
{
40+
$haystack = [
41+
'one',
42+
'two',
43+
'three',
44+
'four'
45+
];
46+
47+
$this->assertFalse(Validators::isAssoc($haystack));
48+
}
49+
2650
public function testWillFailWhenStreamIdsAreNotCorrect(): void
2751
{
2852
$this->expectException(InvalidArgumentException::class);

0 commit comments

Comments
 (0)