diff --git a/path_alias_xt.module b/path_alias_xt.module --- a/path_alias_xt.module +++ b/path_alias_xt.module @@ -89,7 +89,13 @@ function path_alias_xt_url_inbound_alter(&$path, $original_path, $path_language) if (!empty($original_path) && $path == $original_path) { // drupal_get_normal_path() did not find a system path $candidate_alias = $original_path; - while ($pos = strrpos($candidate_alias, '/')) { + // This needs to use explode() and not strrpos() / drupal_substr(), because + // strrpos() is not unicode safe, so unicode characters can lead to an + // endless loop. + $parts = explode('/', $candidate_alias); + $path_suffix = array(); + + while (count($parts) > 0) { // If the truncated path exists as a menu item (incl. paged views), abort. // E.g.: we won't replace and extend the user alias 'admin' in this path: // admin/structure/block/manage/system/navigation/configure, because @@ -97,7 +103,8 @@ function path_alias_xt_url_inbound_alter(&$path, $original_path, $path_language) if ($menu_item_path = _path_alias_xt_get_menu_item($candidate_alias)) { return; } - $candidate_alias = drupal_substr($candidate_alias, 0, $pos); + array_unshift($path_suffix, array_pop($parts)); + $candidate_alias = implode('/', $parts); if ($src = drupal_lookup_path('source', $candidate_alias, $path_language)) { // If 'user' is aliased to MyAccount, then MyAccount/edit needs to // transform to 'user/123/edit'. @@ -105,7 +112,7 @@ function path_alias_xt_url_inbound_alter(&$path, $original_path, $path_language) global $user; $src .= '/' . $user->uid; } - $path = $src . drupal_substr($original_path, $pos); + $path = $src . implode('/', $path_suffix); return; } }