in taxonomy_autocomplete: https://api.drupal.org/api/drupal/modules!taxonomy!taxonomy.pages.inc/function/taxonomy_autocomplete/6 we have the following code:

   // Commas and quotes in terms are special cases, so encode 'em.
      if (strpos($tag->name, ',') !== FALSE || strpos($tag->name, '"') !== FALSE) {
        $n = '"' . str_replace('"', '""', $tag->name) . '"';

Imagine we have the taxonomy term which is exactly the following string:

George "madcow" Stewart

THe above code would cause the taxonomy autocomplete to display:

"George ""madcow"" Stewart"

I have re-implemented the taxonomy_autocomplete in order to work with a single term (no comma separated list of terms allowed). The problem now is that when we want to enter George "madcow" Stewart, a new term "George ""madcow"" Stewart" is created, including all the extra quotes!

I cannot find where and how in core the escape quotes are stripped before insertion to the database…

1 Answer 1


Oh! I just found it:

The function taxonomy_node_save(&$node, $terms) calls drupal_explode_tags()


which has:

// If a user has escaped a term (to demonstrate that it is a group,
// or includes a comma or quote character), we remove the escape
// formatting so to save the term into the database as the user intends.
$tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag)));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.