# HG changeset patch # User Dan # Date 1226066213 18000 # Node ID 25691e0841f1c8805ee83e483695ae087e4d2064 # Parent 145b70bb8999556e2387d98ecc174dff06578c55 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/ diff -r 145b70bb8999 -r 25691e0841f1 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; }