Fixed sanitization of full page IDs with accidental parse of escaped hex character in dirtify_page_id(). Thanks Asterion; see http://forum.enanocms.org/post/20/
authorDan
Fri, 07 Nov 2008 08:56:53 -0500
changeset 308 25691e0841f1
parent 307 145b70bb8999
child 309 cf26ccfd99d8
Fixed sanitization of full page IDs with accidental parse of escaped hex character in dirtify_page_id(). Thanks Asterion; see http://forum.enanocms.org/post/20/
includes/functions.php
--- a/includes/functions.php	Tue Sep 16 08:20:14 2008 -0400
+++ b/includes/functions.php	Fri Nov 07 08:56:53 2008 -0500
@@ -2436,7 +2436,7 @@
   
   // Remove character escapes
   $page_id = dirtify_page_id($page_id);
-
+  
   $pid_clean = preg_replace('/[\w\.\/:;\(\)@\[\]_-]/', 'X', $page_id);
   $pid_dirty = enano_str_split($pid_clean, 1);
 
@@ -2492,6 +2492,23 @@
   {
     return $page_id;
   }
+  
+  $ns_fixed = false;
+  if ( !empty($paths->nslist) )
+  {
+    $namespaces = array();
+    foreach ( $paths->nslist as $ns )
+    {
+      if ( !empty($ns) )
+        $namespaces[] = preg_quote($ns);
+    }
+    $namespaces = implode('|', $namespaces);
+    if ( preg_match("/^($namespaces)/", $page_id, $match) )
+    {
+      $ns_fixed = true;
+      $page_id = preg_replace("/^($namespaces)/", '', $page_id);
+    }
+  }
 
   preg_match_all('/\.[A-Fa-f0-9][A-Fa-f0-9]/', $page_id, $matches);
 
@@ -2504,6 +2521,11 @@
     $page_id = str_replace($matches[0][$id], $char, $page_id);
   }
   
+  if ( $ns_fixed )
+  {
+    $page_id = "{$match[1]}$page_id";
+  }
+  
   return $page_id;
 }