Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.12
diff -u -F^f -r1.12 autocomplete.js
--- misc/autocomplete.js	20 May 2006 07:23:47 -0000	1.12
+++ misc/autocomplete.js	30 Aug 2006 19:12:29 -0000
@@ -254,7 +254,7 @@ function ACDB(uri) {
   var db = this;
   this.timer = setTimeout(function() {
     db.owner.setStatus('begin');
-    db.transport = HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
+    db.transport = HTTPGet(db.uri +'/'+ drupalEncodeURIComponent(searchString, db.uri), db.receive, db);
   }, this.delay);
 }
 
Index: misc/drupal.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/drupal.js,v
retrieving revision 1.27
diff -u -F^f -r1.27 drupal.js
--- misc/drupal.js	23 Aug 2006 04:59:17 -0000	1.27
+++ misc/drupal.js	30 Aug 2006 19:12:30 -0000
@@ -65,7 +65,7 @@ function isJsEnabled() {
 /**
  * Creates an HTTP GET request and sends the response to the callback function.
  *
- * Note that dynamic arguments in the URI should be escaped with encodeURIComponent().
+ * Note that dynamic arguments in the URI should be escaped with drupalEncodeURIComponent().
  */
 function HTTPGet(uri, callbackFunction, callbackParameter) {
   var xmlHttp = new XMLHttpRequest();
@@ -108,7 +108,7 @@ function HTTPPost(uri, callbackFunction,
   if (typeof object == 'object') {
     xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     for (var i in object) {
-      toSend += (toSend ? '&' : '') + i + '=' + encodeURIComponent(object[i]);
+      toSend += (toSend ? '&' : '') + i + '=' + drupalEncodeURIComponent(object[i], uri);
     }
   }
   else {
@@ -387,3 +387,13 @@ function deleteIframe() {
 function $(id) {
   return document.getElementById(id);
 }
+
+/**
+ * Wrapper to address the mod_rewrite url encoding bug
+ * (equivalent of drupal_urlencode() in PHP).
+ */
+function drupalEncodeURIComponent(item, uri) {
+  uri = uri || location.href;
+  item = encodeURIComponent(item).replace('%2F', '/');
+  return uri.indexOf('?q=') ? item : item.replace('%26', '%2526').replace('%23', '%2523');
+}
