Make custom textfield autocomplete compatible with slashes? I have a form which uses a textfield with a custom autocomplete path and it works just as it should. However, I get some unexpected behavior when the title/search string contains a backslash (e.g. '10/07/2016 Meeting').

After some investigation I realized that Drupal seems to interpret those as 4 separate parameters with only the first (in this case 10) being passed to the autocomplete function.  I'm not sure how I can prevent this behaviour as the passing of the string to the form is handled internally by Drupal via the '#autocomplete_path' on the textfield itself.

I checked how entity reference handled this, but it is using an entirely custom field and not the '#autocomplete_path' on a regular textfield and wasn't of much use to me.

However it would seem odd to me that the textfield autocomplete shouldn't be able to support search strings with slashes - I just can't find out how to hook into the Drupal form to encode the string somehow.

How can I make my autocomplete field compatible with slashes?
Take a cue from the Drupal core's taxonomy autocomplete implementation and just recombine the arguments passed into callback function back into one string:

function taxonomy_autocomplete($field_name = '', $tags_typed = '') {

  // If the request has a '/' in the search text, then the menu system will have
  // split it into multiple arguments, recover the intended $tags_typed.
  $args = func_get_args();
  // Shift off the $field_name argument.
  array_shift($args);
  $tags_typed = implode('/', $args);