diff --git a/src/Headers.php b/src/Headers.php index 8f406494..4aacd4b8 100644 --- a/src/Headers.php +++ b/src/Headers.php @@ -373,7 +373,7 @@ public function get($name) $key = $this->normalizeFieldName($name); $results = []; - foreach (array_keys($this->headersKeys, $key) as $index) { + foreach (array_keys($this->headersKeys, $key, true) as $index) { if ($this->headers[$index] instanceof Header\GenericHeader) { $results[] = $this->lazyLoadHeader($index); } else { @@ -403,7 +403,7 @@ public function get($name) public function has($name) { $name = $this->normalizeFieldName($name); - return in_array($name, $this->headersKeys); + return in_array($name, $this->headersKeys, true); } /** diff --git a/test/HeadersTest.php b/test/HeadersTest.php index 85ea0385..8a8f93aa 100644 --- a/test/HeadersTest.php +++ b/test/HeadersTest.php @@ -634,4 +634,16 @@ public function testCanInjectAlternateHeaderLocatorInstance(): void $headers->setHeaderLocator($locator); $this->assertSame($locator, $headers->getHeaderLocator()); } + + public function testStrictKeyComparisonInHas(): void + { + $headers = Mail\Headers::fromString("000: foo-bar"); + $this->assertFalse($headers->has('0')); + } + + public function testStrictKeyComparisonInGet(): void + { + $headers = Mail\Headers::fromString("000: foo-bar"); + $this->assertFalse($headers->get('0')); + } }