From 71d98087963d557e45bc015e5989e3cef7808aae Mon Sep 17 00:00:00 2001 From: Bob Vincent Date: Mon, 17 Oct 2011 17:27:17 -0400 Subject: [PATCH] Issue #93854 by moonray, becw, Dave Reid, pounard, das-peter, Steven Jones, c960657: Allow autocompletion to contain slashes. --- misc/autocomplete.js | 2 +- modules/taxonomy/taxonomy.test | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletions(-) diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 5e85be44fc5f372e1d4a6ccc4cef2454e3be7376..da3b82074dcf399dc3fa1cd798b36bfb09e91176 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -290,7 +290,7 @@ Drupal.ACDB.prototype.search = function (searchString) { // Ajax GET request for autocompletion. $.ajax({ type: 'GET', - url: db.uri + '/' + encodeURIComponent(searchString), + url: db.uri + '/' + Drupal.encodePath(searchString), dataType: 'json', success: function (matches) { if (typeof matches.status == 'undefined' || matches.status != 0) { diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 9a89b9c98ff63924d7d592c7408efe70cdb756d4..254cb3e755aeac09feccccb28a233b9d0af0e22d 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -641,6 +641,31 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { } /** + * Test term autocompletion edge cases. + */ + function testTermAutocompletion() { + $base_len = 5; + $base = $this->randomName($base_len); + // Add a term with a slash in the name. + $first_term = $this->createTerm($this->vocabulary); + $first_term->name = $base . '/' . $this->randomName(); + taxonomy_term_save($first_term); + // Add another term that differs after the slash character. + $search_term = $this->createTerm($this->vocabulary); + $search_term->name = $base . '/' . $this->randomName(); + taxonomy_term_save($search_term); + + // Try to autocomplete a term name that contains a slash. + // We should only get a single term returned. + $input = substr($search_term->name, 0, $base_len + 3); + $url = 'taxonomy/autocomplete/taxonomy_'; + $url .= $this->vocabulary->machine_name . '/' . $input; + $this->drupalGet($url); + $target = array($search_term->name => check_plain($search_term->name)); + $this->assertRaw(drupal_json_encode($target), t('Autocomplete returns term %term_name after typing the first %num letters, including a slash in the name.', array('%term_name' => $search_term->name, '%num' => $base_len + 3))); + } + + /** * Save, edit and delete a term using the user interface. */ function testTermInterface() { -- 1.7.5.4