Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 5781)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java	(revision 5782)
@@ -4,13 +4,12 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
-import java.awt.geom.Area;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.net.URL;
+import java.net.URLEncoder;
 import java.util.Collection;
 import java.util.concurrent.Future;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
-import org.xml.sax.SAXException;
 
 import org.openstreetmap.josm.Main;
@@ -30,4 +29,5 @@
 import org.openstreetmap.josm.io.OsmTransferCanceledException;
 import org.openstreetmap.josm.io.OsmTransferException;
+import org.xml.sax.SAXException;
 
 /**
@@ -116,4 +116,19 @@
     }
 
+    protected final String encodePartialUrl(String url, String safePart) {
+        if (url != null && safePart != null) {
+            int pos = url.indexOf(safePart);
+            if (pos > -1) {
+                pos += safePart.length();
+                try {
+                    return url.substring(0, pos) + URLEncoder.encode(url.substring(pos), "UTF-8").replaceAll("\\+", "%20");
+                } catch (UnsupportedEncodingException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return url;
+    }
+    
     /**
      * Loads a given URL from the OSM Server
@@ -122,4 +137,10 @@
      */
     public Future<?> loadUrl(boolean new_layer, String url, ProgressMonitor progressMonitor) {
+        if (url.matches(PATTERN_OVERPASS_API_URL)) {
+            url = encodePartialUrl(url, "/interpreter?data="); // encode only the part after the = sign
+            
+        } else if (url.matches(PATTERN_OVERPASS_API_XAPI_URL)) {
+            url = encodePartialUrl(url, "/xapi?"); // encode only the part after the ? sign
+        }
         downloadTask = new DownloadTask(new_layer,
                 new OsmServerLocationReader(url),
