diff --git a/includes/common.inc b/includes/common.inc index 3b4bf58..8bec2c5 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -7419,7 +7419,7 @@ function drupal_explode_tags($tags) { // formatting so to save the term into the database as the user intends. $tag = trim(str_replace('""', '"', preg_replace('/^"(.*)"$/', '\1', $tag))); if ($tag != "") { - $tags[] = $tag; + $tags[] = str_replace('[--SLASH--]', '/', $tag); } } diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 8f7ac60..275d0f3 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -293,7 +293,7 @@ Drupal.ACDB.prototype.search = function (searchString) { // encodeURIComponent to allow autocomplete search terms to contain slashes. $.ajax({ type: 'GET', - url: db.uri + '/' + Drupal.encodePath(searchString), + url: db.uri + '/' + Drupal.encodePath(searchString).replace('%2F', '[--SLASH--]'), dataType: 'json', success: function (matches) { if (typeof matches.status == 'undefined' || matches.status != 0) { diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index 975ff12..b6b341f 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -119,13 +119,6 @@ function taxonomy_term_feed($term) { * @see taxonomy_field_widget_info() */ 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); - // Make sure the field exists and is a taxonomy field. if (!($field = field_info_field($field_name)) || $field['type'] !== 'taxonomy_term_reference') { // Error string. The JavaScript handler will realize this is not JSON and diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 665f9ae..6073008 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -11,6 +11,14 @@ class TaxonomyWebTestCase extends DrupalWebTestCase { /** + * Repeats the JS processing done to the input before sending it to the + * autocomplete URL. + */ + function prepareAutocompleteInput($input) { + return str_replace('%2F', '[--SLASH--]', drupal_encode_path($input)); + } + + /** * Returns a new vocabulary with random properties. */ function createVocabulary() { @@ -751,7 +759,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // Try to autocomplete a term name that matches both terms. // We should get both term in a json encoded string. - $input = '10/'; + $input = $this->prepareAutocompleteInput('10/'); $path = 'taxonomy/autocomplete/taxonomy_'; $path .= $this->vocabulary->machine_name . '/' . $input; // The result order is not guaranteed, so check each term separately. @@ -763,7 +771,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // Try to autocomplete a term name that matches first term. // We should only get the first term in a json encoded string. - $input = '10/16'; + $input = this->prepareAutocompleteInput('10/16'); $url = 'taxonomy/autocomplete/taxonomy_'; $url .= $this->vocabulary->machine_name . '/' . $input; $this->drupalGet($url); @@ -771,7 +779,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.'); // Try to autocomplete a term name with both a comma and a slash. - $input = '"term with, comma and / a'; + $input = this->prepareAutocompleteInput('"term with, comma and / a'); $url = 'taxonomy/autocomplete/taxonomy_'; $url .= $this->vocabulary->machine_name . '/' . $input; $this->drupalGet($url);