Permalink
Browse files

Merge branch 'hotfix/2421'

Close #2421
  • Loading branch information...
2 parents 879544b + d4c73cf commit 7d49e8e32f6500d64e346d465aca779291bf1d54 @weierophinney weierophinney committed Oct 3, 2012
Showing with 14 additions and 2 deletions.
  1. +1 −1 library/Zend/Http/Header/SetCookie.php
  2. +13 −1 tests/ZendTest/Http/Header/SetCookieTest.php
@@ -487,7 +487,7 @@ public function isSessionCookie()
public function isValidForRequest($requestDomain, $path, $isSecure = false)
{
- if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) !== false)) {
+ if ($this->getDomain() && (strrpos($requestDomain, $this->getDomain()) === false)) {
return false;
}
@@ -153,7 +153,19 @@ public function testSetCookieCanAppendOtherHeadersInWhenCreatingString()
$this->assertEquals($target, $headerLine);
}
- /** Implmentation specific tests here */
+ public function testIsValidForRequestSubdomainMatch()
+ {
+ $setCookieHeader = new SetCookie(
+ 'myname', 'myvalue', 'Wed, 13-Jan-2021 22:23:01 GMT',
+ '/accounts', '.foo.com', true, true, 99, 9
+ );
+ $this->assertTrue($setCookieHeader->isValidForRequest('bar.foo.com', '/accounts', true));
+ $this->assertFalse($setCookieHeader->isValidForRequest('bar.foooo.com', '/accounts', true)); // false because of domain
+ $this->assertFalse($setCookieHeader->isValidForRequest('bar.foo.com', '/accounts', false)); // false because of isSecure
+ $this->assertFalse($setCookieHeader->isValidForRequest('bar.foo.com', '/somethingelse', true)); // false because of path
+ }
+
+ /** Implementation specific tests here */
/**
* @group ZF2-169

0 comments on commit 7d49e8e

Please sign in to comment.