Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.23
diff -u -r1.23 autocomplete.js
--- misc/autocomplete.js	4 Jan 2008 11:53:21 -0000	1.23
+++ misc/autocomplete.js	30 Jul 2010 04:09:10 -0000
@@ -203,14 +203,20 @@
   var ul = document.createElement('ul');
   var ac = this;
   for (key in matches) {
-    var li = document.createElement('li');
-    $(li)
-      .html('<div>'+ matches[key] +'</div>')
-      .mousedown(function () { ac.select(this); })
-      .mouseover(function () { ac.highlight(this); })
-      .mouseout(function () { ac.unhighlight(this); });
-    li.autocompleteValue = key;
-    $(ul).append(li);
+    /* Iterating over an Array object can be dangerous if JavaScript libraries
+     * extend the Array object, since functions will show up as elements, too.
+     * So, we limit iteration only to string properties of the object.
+     */
+    if (typeof matches[key] == 'string') {
+      var li = document.createElement('li');
+      $(li)
+        .html('<div>'+ matches[key] +'</div>')
+        .mousedown(function () { ac.select(this); })
+        .mouseover(function () { ac.highlight(this); })
+        .mouseout(function () { ac.unhighlight(this); });
+      li.autocompleteValue = key;
+      $(ul).append(li);
+    }
   }
 
   // Show popup with matches, if any
