[pmwiki-users] [Bug] Clean URLs + Apache MultiViews

Julien Charbon julien.charbon at gmail.com
Thu Aug 9 07:44:33 CDT 2007


pmwiki: pmwiki-2.2.0-beta63

  Hi, I configure pmwiki to get clean URLs using Apache MultiViews as 
defined in:

Wrapper using Apache MultiViews
http://www.pmwiki.org/wiki/Cookbook/CleanUrls#multiviews

  And I guess I find a bug. You have in pmwiki.php:296:

$pagename = @$_REQUEST['n'];
if (!$pagename) $pagename = @$_REQUEST['pagename'];
if (!$pagename &&
     preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
       $_SERVER['REQUEST_URI'],$match))
   $pagename = urldecode($match[1]);

Or with clean URLs using Apache MultiViews configuration on a request on :

http://host/wiki/Group/Page

you have

$_SERVER['SCRIPT_NAME'] is equal to "wiki.php"
$_SERVER['REQUEST_URI'] is equal to /wiki/Group/Page

thus:

preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
       $_SERVER['REQUEST_URI'],$match))

failed and I get an empty pagename value.

Below a patch a correct this issue for me. This not the final correction 
but this patch show precisely where is the issue.

  Just ask if you need for more information.

  Thank again for this very good piece of code that is pmwiki.

--
Julien

--- /home/julien/wiki/pmwiki/pmwiki.php 2007-07-31 23:08:16.000000000 +0200
+++ pmwiki.php  2007-08-09 14:33:46.000000000 +0200
@@ -299,6 +299,11 @@
      preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
        $_SERVER['REQUEST_URI'],$match))
    $pagename = urldecode($match[1]);
+if (!$pagename &&
+    preg_match('!^'.preg_replace('/(.*?)\\.php.?/', '$1',
+      preg_quote($_SERVER['SCRIPT_NAME'],'!')).'/?([^?]*)!',
+        $_SERVER['REQUEST_URI'],$match))
+  $pagename = urldecode($match[1]);
  if (preg_match('/[\\x80-\\xbf]/',$pagename))
    $pagename=utf8_decode($pagename);
  $pagename = preg_replace('![^[:alnum:]\\x80-\\xff]+$!','',$pagename);




More information about the pmwiki-users mailing list