diff --git a/includes/common.inc b/includes/common.inc index 7d0bf85..7c9d212 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3746,24 +3746,25 @@ function watchdog_severity_levels() { * * @see drupal_implode_tags() */ -function drupal_explode_tags($tags) { +function drupal_explode_tags($tags, $autocomplete=false) { // This regexp allows the following types of user input: // this, "somecompany, llc", "and ""this"" w,o.rks", foo bar $regexp = '%(?:^|,\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x'; preg_match_all($regexp, $tags, $matches); $typed_tags = array_unique($matches[1]); - $tags = array(); foreach ($typed_tags as $tag) { // 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))); - if ($tag != "") { + + if (!$autocomplete) $tag = preg_replace('/^"(.*)"$/', '\1', $tag); + $tag = trim(str_replace('""', '"', $tag)); + + if ($tag != "") { $tags[] = $tag; } } - return $tags; } diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index aa3e68d..9253964 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -112,8 +112,7 @@ function theme_taxonomy_term_page($tids, $result) { */ function taxonomy_autocomplete($vid, $string = '') { // The user enters a comma-separated list of tags. We only autocomplete the last tag. - $array = drupal_explode_tags($string); - + $array = drupal_explode_tags($string,true); // Fetch last tag $last_string = trim(array_pop($array)); $matches = array();