瀏覽代碼

ZF-10506: preg_quote hostname before passing to PCRE

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23230 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 15 年之前
父節點
當前提交
f6278e74f5
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 1 1
      library/Zend/Http/Cookie.php
  2. 8 0
      tests/Zend/Http/CookieTest.php

+ 1 - 1
library/Zend/Http/Cookie.php

@@ -395,7 +395,7 @@ class Zend_Http_Cookie
 
         // Check for either exact match or suffix match
         return ($cookieDomain == $host ||
-                preg_match("/\.$cookieDomain$/", $host));
+                preg_match('/\.' . preg_quote($cookieDomain) . '$/', $host));
     }
 
     /**

+ 8 - 0
tests/Zend/Http/CookieTest.php

@@ -451,6 +451,14 @@ class Zend_Http_CookieTest extends PHPUnit_Framework_TestCase
     }
 
     /**
+     * @group ZF-10506
+     */
+    public function testPregMatchIsQuoted()
+    {
+        $this->assertFalse(Zend_Http_Cookie::matchCookieDomain('foo.bar.com', 'www.foozbar.com'));
+    }
+
+    /**
      * Data Providers
      */