Fixed bad URL interpretation on CGI and Apache wrongly supplying PATH_INFO when directory index requested
authorDan
Tue, 01 Apr 2008 01:24:10 -0400
changeset 515 be77f34d03af
parent 514 ecbfb747743e
child 516 9a52679143db
Fixed bad URL interpretation on CGI and Apache wrongly supplying PATH_INFO when directory index requested
includes/paths.php
--- a/includes/paths.php	Sun Mar 30 07:24:48 2008 -0700
+++ b/includes/paths.php	Tue Apr 01 01:24:10 2008 -0400
@@ -107,13 +107,21 @@
   function parse_url($sanitize = true)
   {
     $title = '';
-    if( isset($_GET['title']) )
+    if ( isset($_GET['title']) )
     {
       $title = $_GET['title'];
     }
-    elseif( isset($_SERVER['PATH_INFO']) )
+    else if ( isset($_SERVER['PATH_INFO']) )
     {
-      $title = substr($_SERVER['PATH_INFO'], ( strpos($_SERVER['PATH_INFO'], '/') ) + 1 );
+      // fix for apache + CGI (occurred on a GoDaddy server, thanks mm3)
+      if ( @substr(@$_SERVER['GATEWAY_INTERFACE'], 0, 3) === 'CGI' && $_SERVER['PATH_INFO'] == scriptPath . '/index.php' )
+      {
+        // do nothing; ignore PATH_INFO
+      }
+      else
+      {
+        $title = substr($_SERVER['PATH_INFO'], ( strpos($_SERVER['PATH_INFO'], '/') ) + 1 );
+      }
     }
     else
     {