[tor-commits] [flashproxy/master] Provide a default of "/" for PATH_INFO.

dcf at torproject.org dcf at torproject.org
Sun Sep 23 15:53:25 UTC 2012


commit c455b4b54960e6ad344af554a357db594e135128
Author: David Fifield <david at bamsoftware.com>
Date:   Sun Sep 23 00:36:58 2012 -0700

    Provide a default of "/" for PATH_INFO.
    
    thttpd doesn't set PATH_INFO if there is nothing after the CGI name in
    the path.
---
 facilitator/facilitator.cgi |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/facilitator/facilitator.cgi b/facilitator/facilitator.cgi
index 8975aa7..a453a20 100755
--- a/facilitator/facilitator.cgi
+++ b/facilitator/facilitator.cgi
@@ -2,7 +2,6 @@
 
 import cgi
 import os
-import os.path
 import socket
 import sys
 import urllib
@@ -69,18 +68,16 @@ def get_reg(proxy_addr):
         exit_error(500)
 
 method = os.environ.get("REQUEST_METHOD")
-path_info = os.environ.get("PATH_INFO")
 proxy_addr = (os.environ.get("REMOTE_ADDR"), None)
+path_info = os.environ.get("PATH_INFO") or "/"
 
-if not method or not path_info or not proxy_addr[0]:
+if not method or not proxy_addr[0]:
     exit_error(400)
 
-path = os.path.normpath(path_info)
-
 fs = cgi.FieldStorage()
 
 def do_get():
-    if path != "/":
+    if path_info != "/":
         exit_error(400)
     try:
         reg = get_reg(proxy_addr) or ""
@@ -96,7 +93,7 @@ Access-Control-Allow-Origin: *\r
     sys.stdout.write(urllib.urlencode(reg))
 
 def do_post():
-    if path != "/":
+    if path_info != "/":
         exit_error(400)
     client_specs = fs.getlist("client")
     if len(client_specs) != 1:





More information about the tor-commits mailing list