From a6e88a923c3844af6e59a18c9cb0a9dd998abf7b Mon Sep 17 00:00:00 2001
From: Angie Byron <webchick@24967.no-reply.drupal.org>
Date: Sat, 5 Sep 2009 12:03:31 +0000
Subject: [PATCH] #159762 by paul.lovvik and jp.stacey: Fixed Autocomplete
 errors from whitespace entry.

---
 misc/autocomplete.js | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/misc/autocomplete.js b/misc/autocomplete.js
index 489e2fb1b561..8c839c7c31f1 100644
--- a/misc/autocomplete.js
+++ b/misc/autocomplete.js
@@ -256,7 +256,8 @@ Drupal.ACDB.prototype.search = function (searchString) {
 
   // See if this string needs to be searched for anyway.
   searchString = searchString.replace(/^\s+|\s+$/, '');
-  if (searchString.charAt(searchString.length - 1) == ',') {
+  if (searchString.length <= 0 ||
+    searchString.charAt(searchString.length - 1) == ',') {
     return;
   }
 
-- 
GitLab