浏览代码

[HttpFoundation] added missing trustProxy condition

Kris Wallsmith 13 年之前
父节点
当前提交
d67d419f3c
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Symfony/Component/HttpFoundation/Request.php

+ 5 - 1
src/Symfony/Component/HttpFoundation/Request.php

@@ -562,7 +562,11 @@ class Request
      */
     public function getPort()
     {
-        return $this->headers->get('X-Forwarded-Port') ?: $this->server->get('SERVER_PORT');
+        if (self::$trustProxy && $this->headers->has('X-Forwarded-Port')) {
+            return $this->headers->get('X-Forwarded-Port');
+        } else {
+            return $this->server->get('SERVER_PORT');
+        }
     }
 
     /**