Encoded strings in hook_menu wildcard case menu item to lose access I'm trying to create a menu link within the admin area that includes a urlencoded() copy of the current URL as a tail to the link URL, so that the code invoked can redirect back to the current page when it's done its job.

However, as soon as the string returned by my _to_arg() callback contains a URLencoded string (Or specifically any string containing a % character), Drupal drops access rights to that menu, and the link is hidden.

Sample code below:

/**
 * Implements hook_menu().
 */
function admin_bar_menu() {

  $items['admin/bar/%test'] = array(
    'title' =&gt; 'Admin Bar Test',
    'page callback' =&gt; '_admin_bar_redirector',
    'page arguments' =&gt; array(2),
    'access callback' =&gt; 'user_access',
    'type' =&gt; MENU_NORMAL_ITEM,
    'weight' =&gt; 15,
  );

  return $items;
}



function test_to_arg ( $arg, $map, $index ) {

  // 1. Link is shown, but is of the form /admin/bar/admin/appearance,
  // so the desired string (admin/appearance) can't be retrieved
    // return $_GET['q'];

  // 2. Link is hidden
  // return urlencode($_GET['q']);

  // 3. Link is hidden
  // return 'foo%bar';

}


function _admin_bar_redirector($destination) {
    drupal_goto($destination);
}


I'm pretty sure this is being caused by the following code in menu.inc (Line 911 - d7.14):

// Skip links containing untranslated arguments.

if (strpos($item['href'], '%') !== FALSE) {
  $item['access'] = FALSE;
  return FALSE;
}


Can anyone suggest a potential avenue for a fix to the code in menu.inc - or is there a better way to achieve what I'm trying to do?
I've assumed this needs fixing in core, so logged it here - any insights welcome!

http://drupal.org/node/1822004