Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.542
diff -u -F^f -r1.542 common.inc
--- includes/common.inc	8 Jun 2006 21:23:40 -0000	1.542
+++ includes/common.inc	21 Jun 2006 13:33:37 -0000
@@ -1284,11 +1284,24 @@ function drupal_to_js($var) {
  * are urlencoded() when passed through url() and do not require urlencoding()
  * of individual components.
  *
+ * Notes:
+ * - For esthetic reasons, we do not escape slashes. This also avoids a 'feature'
+ *   in Apache where it 404s on any path containing '%2F'.
+ * - To avoid problems with mod_rewrite's built-in unescaping, we double-escape
+ *   ampersands and hashes, when clean URLs are used.
+ *
  * @param $text
  *   String to encode
  */
 function drupal_urlencode($text) {
-  return str_replace('%2F', '/', urlencode($text));
+  if (variable_get('clean_url', '0')) {
+    return str_replace(array('%2F', '%26', '%23'),
+                       array('/', '%2526', '%2523'),
+                       urlencode($text));
+  }
+  else {
+    return str_replace('%2F', '/', urlencode($text));    
+  }
 }
 
 /**
