diff -Naur pmwiki.orig/pmwiki.php pmwiki/pmwiki.php
--- pmwiki.orig/pmwiki.php	2007-01-11 23:36:49.000000000 +0000
+++ pmwiki/pmwiki.php	2007-01-12 00:12:50.000000000 +0000
@@ -285,16 +285,22 @@
 elseif (isset($_POST['action'])) $action = $_POST['action'];
 else $action = 'browse';
 
-$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]);
-if (preg_match('/[\\x80-\\xbf]/',$pagename)) 
-  $pagename=utf8_decode($pagename);
-$pagename = preg_replace('![^[:alnum:]\\x80-\\xff]+$!','',$pagename);
-$FmtPV['$RequestedPage'] = "'".htmlspecialchars($pagename, ENT_QUOTES)."'";
+if ( !empty($_REQUEST['n']) )
+    $pagename = $_REQUEST['n'];
+elseif ( !empty($_REQUEST['pagename']) )
+    $pagename = $_REQUEST['pagename'];
+elseif ( preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',$_SERVER['REQUEST_URI'],$match) )
+    $pagename = urldecode($match[1]);
+
+if ( !empty($pagename) ) {
+    $pagename = preg_replace('![^[:alnum:]\\x80-\\xff]+$!','',$pagename);
+    $FmtPV['$RequestedPage'] = "'".htmlspecialchars($pagename, ENT_QUOTES)."'";
+}
+else {
+    $pagename = '';
+    $FmtPV['$RequestedPage'] = '\'\'';
+}
+
 $Cursor['*'] = &$pagename;
 
 if (file_exists("$FarmD/local/farmconfig.php")) 
@@ -312,28 +318,34 @@
 if (IsEnabled($EnableStdConfig,1))
   include_once("$FarmD/scripts/stdconfig.php");
 
-foreach((array)$InterMapFiles as $f) {
-  $f = FmtPageName($f, $pagename);
-  if (($v = @file($f))) 
-    $v = preg_replace('/^\\s*(?>\\w[-\\w]*)(?!:)/m', '$0:', implode('', $v));
-  else if (PageExists($f)) {
-    $p = ReadPage($f, READPAGE_CURRENT);
-    $v = $p['text'];
-  } else continue;
-  if (!preg_match_all("/^\\s*(\\w[-\\w]*:)[^\\S\n]+(\\S*)/m", $v, 
-                      $match, PREG_SET_ORDER)) continue;
-  foreach($match as $m) {
-    if (strpos($m[2], '$1') === false) $m[2] .= '$1';
-    $LinkFunctions[$m[1]] = 'LinkIMap';
-    $IMap[$m[1]] = FmtPageName($m[2], $pagename);
-  }
+
+if ( !empty($InterMapFiles) ) {
+    assert($InterMapFiles);
+
+    foreach ( $InterMapFiles as $f ) {
+        $f = FmtPageName( $f, $pagename );
+        if ( file_exists($f) && ($v = @file($f)) )
+            $v = preg_replace('/^\\s*(?>\\w[-\\w]*)(?!:)/m', '$0:', implode('', $v));
+        elseif ( PageExists($f) ) {
+            $p = ReadPage( $f, READPAGE_CURRENT );
+            $v = $p['text'];
+        } else continue;
+
+        if (!preg_match_all("/^\\s*(\\w[-\\w]*:)[^\\S\n]+(\\S*)/m", $v,$match, PREG_SET_ORDER)) continue;
+
+        foreach( $match as $m ) {
+            if ( strpos($m[2], '$1') === false ) $m[2] .= '$1';
+            $LinkFunctions[$m[1]] = 'LinkIMap';
+            $IMap[$m[1]] = FmtPageName($m[2], $pagename);
+        }
+    }
 }
 
 $LinkPattern = implode('|',array_keys($LinkFunctions));
 SDV($LinkPageCreateSpaceFmt,$LinkPageCreateFmt);
 
-$ActionTitle = FmtPageName(@$ActionTitleFmt[$action],$pagename);
-if (!function_exists(@$HandleActions[$action])) $action='browse';
+$ActionTitle = empty($ActionTitleFmt[$action]) ? '' : FmtPageName($ActionTitleFmt[$action],$pagename);
+if ( empty($HandleActions[$action]) || !function_exists($HandleActions[$action]) ) $action = 'browse';
 SDV($HandleAuth[$action], 'read');
 $HandleActions[$action]($pagename, $HandleAuth[$action]);
 Lock(0);
@@ -549,7 +561,7 @@
   $str = preg_replace('/[#?].*$/', '', $str);
   $m = preg_split('/[.\\/]/', $str);
   if (count($m)<1 || count($m)>2 || $m[0]=='') return '';
-  if ($m[1] > '') {
+  if (!empty($m[1])) {
     $group = preg_replace(array_keys($MakePageNamePatterns),
                array_values($MakePageNamePatterns), $m[0]);
     $name = preg_replace(array_keys($MakePageNamePatterns),
@@ -828,7 +840,7 @@
   }
   function ls($pats=NULL) {
     global $GroupPattern, $NamePattern;
-    StopWatch("PageStore::ls begin {$this->dir}");
+    StopWatch("PageStore::ls begin");
     $pats=(array)$pats; 
     array_push($pats, "/^$GroupPattern\.$NamePattern$/");
     $dir = $this->pagefile('$Group.$Name');
@@ -847,10 +859,10 @@
         if ($dirslash == $maxslash) $o[] = $pagefile;
       }
       closedir($dfp);
-      StopWatch("PageStore::ls merge {$this->dir}");
+      StopWatch("PageStore::ls merge {$dir}");
       $out = array_merge($out, MatchPageNames($o, $pats));
     }
-    StopWatch("PageStore::ls end {$this->dir}");
+    StopWatch("PageStore::ls end {$dir}");
     return $out;
   }
 }
diff -Naur pmwiki.orig/scripts/pagelist.php pmwiki/scripts/pagelist.php
--- pmwiki.orig/scripts/pagelist.php	2007-01-11 23:36:49.000000000 +0000
+++ pmwiki/scripts/pagelist.php	2007-01-12 00:09:09.000000000 +0000
@@ -91,9 +91,9 @@
 foreach(array('random', 'size', 'time', 'ctime') as $o) 
   SDV($PageListSortCmp[$o], "@(\$PCache[\$x]['$o']-\$PCache[\$y]['$o'])");
 
-#define PAGELIST_PRE       1
-#define PAGELIST_ITEM      2
-#define PAGELIST_POST      4
+define( 'PAGELIST_PRE',       1 );
+define( 'PAGELIST_ITEM',      2 );
+define( 'PAGELIST_POST',      4 );
 
 ## SearchBox generates the output of the (:searchbox:) markup.
 ## If $SearchBoxFmt is defined, that is used, otherwise a searchbox
@@ -106,7 +106,7 @@
     'value' => str_replace("'", "&#039;", $SearchQuery)));
   $opt = array_merge((array)$SearchBoxOpt, @$_GET, (array)$opt);
   $opt['action'] = 'search';
-  $target = ($opt['target']) 
+  $target = (!empty($opt['target'])) 
             ? MakePageName($pagename, $opt['target']) : $pagename;
   $out = FmtPageName(" class='wikisearch' action='\$PageUrl' method='get'>",
                      $target);
@@ -186,6 +186,8 @@
 
   asort($PageListFilters);
   $opt['=phase'] = PAGELIST_PRE; $list=array(); $pn=NULL; $page=NULL;
+  $itemfilters = array();
+  $postfilters = array();
   foreach($PageListFilters as $fn => $v) {
     $ret = $fn($list, $opt, $pagename, $page);
     if ($ret & PAGELIST_ITEM) $itemfilters[] = $fn;
@@ -229,7 +231,10 @@
 
   StopWatch('PageListSources begin');
   ## add the list= option to our list of pagename filter patterns
-  $opt['=pnfilter'] = array_merge((array)@$opt['=pnfilter'], 
+  if ( !isset($opt['=pnfilter']) )
+    $opt['=pnfilter'] = array();
+  if ( isset($SearchPatterns[$opt['list']]) )
+    $opt['=pnfilter'] = array_merge((array)@$opt['=pnfilter'], 
                                   (array)$SearchPatterns[$opt['list']]);
 
   if (@$opt['group']) $opt['=pnfilter'][] = FixGlob($opt['group'], '$1$2.*');
@@ -260,7 +265,7 @@
   switch ($opt['=phase']) {
     case PAGELIST_PRE:
       $FmtV['$MatchSearched'] = count($list);
-      $incl = array(); $inclp = array();
+      $incl = array(); $excl = array();
       foreach((array)@$opt[''] as $i) { $incl[] = $i; }
       foreach((array)@$opt['+'] as $i) { $incl[] = $i; }
       foreach((array)@$opt['-'] as $i) { $excl[] = $i; }
@@ -363,6 +368,7 @@
 
   ## case PAGELIST_POST
   StopWatch('PageListSort begin');
+  $code = '';
   foreach(preg_split('/[\\s,|]+/', $order, -1, PREG_SPLIT_NO_EMPTY) as $o) {
     if ($o{0} == '-') { $r = '-'; $o = substr($o, 1); }
     else $r = '';
@@ -389,7 +395,8 @@
   $form = RetrieveAuthPage($pagename, $level, true, READPAGE_CURRENT);
   if (!$form) Abort("?unable to read $pagename");
   PCache($pagename, $form);
-  $text = preg_replace('/\\[([=@])(.*?)\\1\\]/s', ' ', $form['text']);
+  $text = isset($form['text']) ? $form['text'] : '';
+  $text = preg_replace('/\\[([=@])(.*?)\\1\\]/s', ' ', $text);
   if (!preg_match('/\\(:searchresults(\\s.*?)?:\\)/', $text))
     foreach((array)$PageSearchForm as $formfmt) {
       $form = ReadPage(FmtPageName($formfmt, $pagename), READPAGE_CURRENT);
diff -Naur pmwiki.orig/scripts/xlpage-utf-8.php pmwiki/scripts/xlpage-utf-8.php
--- pmwiki.orig/scripts/xlpage-utf-8.php	2007-01-11 23:36:49.000000000 +0000
+++ pmwiki/scripts/xlpage-utf-8.php	2007-01-11 23:57:02.000000000 +0000
@@ -22,13 +22,17 @@
 
 $Charset = 'UTF-8';
 $HTTPHeaders[] = 'Content-type: text/html; charset=UTF-8';
-$pagename = $_REQUEST['n'];
-if (!$pagename) $pagename = $_REQUEST['pagename'];
-if (!$pagename &&
-      preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',
-          $_SERVER['REQUEST_URI'],$match))
+if ( !empty($_REQUEST['n']) )
+    $pagename = $_REQUEST['n'];
+elseif ( !empty($_REQUEST['pagename']) )
+    $pagename = $_REQUEST['pagename'];
+elseif ( preg_match('!^'.preg_quote($_SERVER['SCRIPT_NAME'],'!').'/?([^?]*)!',$_SERVER['REQUEST_URI'],$match) )
     $pagename = urldecode($match[1]);
-$pagename = preg_replace('!/+$!','',$pagename);
+
+if ( !empty($pagename) )
+    $pagename = preg_replace('!/+$!','',$pagename);
+else
+    $pagename = '';
 
 $GroupPattern = '[\\w\\x80-\\xfe]+(?:-[[\\w\\x80-\\xfe]+)*';
 $NamePattern = '[\\w\\x80-\\xfe]+(?:-[[\\w\\x80-\\xfe]+)*';