浏览代码

[HttpFoundation] Fixed coding style, fixed wrong parameter method, added omitted split ip and added upper limit to the netmask ip

Dominique Bongiraud 14 年之前
父节点
当前提交
73daccd6c3
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      src/Symfony/Component/HttpFoundation/RequestMatcher.php

+ 10 - 4
src/Symfony/Component/HttpFoundation/RequestMatcher.php

@@ -61,7 +61,13 @@ class RequestMatcher implements RequestMatcherInterface
      */
     public function matchMethod($method)
     {
-        $this->methods = array_map(function ($m) { return strtolower($m); }, is_array($method) ? $method : array($method));
+        $this->methods = array_map(
+            function ($m)
+            {
+                return strtolower($m);
+            },
+            is_array($method) ? $method : array($method)
+        );
     }
 
     /**
@@ -98,7 +104,7 @@ class RequestMatcher implements RequestMatcherInterface
             return false;
         }
 
-        if (null !== $this->ip && !$this->checkIp($this->host, $request->getClientIp())) {
+        if (null !== $this->ip && !$this->checkIp($request->getClientIp())) {
             return false;
         }
 
@@ -108,9 +114,9 @@ class RequestMatcher implements RequestMatcherInterface
     protected function checkIp($ip)
     {
         if (false !== strpos($this->ip, '/')) {
-            list($address, $netmask) = $this->ip;
+            list($address, $netmask) = explode('/', $this->ip);
 
-            if ($netmask <= 0) {
+            if ($netmask < 1 || $netmask > 32) {
                 return false;
             }
         } else {