Index: trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java	(revision 13877)
+++ trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java	(revision 13878)
@@ -432,8 +432,13 @@
                         // TODO should we handle also POST?
                         if ("GET".equalsIgnoreCase(mode) && getMapUrl != null && !"".equals(getMapUrl)) {
-                            if (getMapUrl.endsWith("?")) {
-                                this.getMapUrl = getMapUrl;
-                            } else {
-                                this.getMapUrl = getMapUrl + "?";
+                            try {
+                                String query = (new URL(getMapUrl)).getQuery();
+                                if (query == null || query.isEmpty()) {
+                                    this.getMapUrl = getMapUrl + "?";
+                                } else {
+                                    this.getMapUrl = getMapUrl;
+                                }
+                            } catch (MalformedURLException e) {
+                                throw new XMLStreamException(e);
                             }
                         }
Index: trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java	(revision 13877)
+++ trunk/test/unit/org/openstreetmap/josm/io/imagery/WMSImageryTest.java	(revision 13878)
@@ -91,7 +91,7 @@
                 );
         WMSImagery wms = new WMSImagery(tileServer.url("any"));
-        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k", wms.buildRootUrl());
+        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?", wms.buildRootUrl());
         assertEquals("wms.hgis.cartomatic.pl", wms.getLayers().get(0).getName());
-        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25kFORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&"
+        assertEquals("http://wms.hgis.cartomatic.pl/topo/3857/m25k?FORMAT=image/png&TRANSPARENT=TRUE&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&"
                 + "LAYERS=wms.hgis.cartomatic.pl&STYLES=&SRS={proj}&WIDTH={width}&HEIGHT={height}&BBOX={bbox}",
                 wms.buildGetMapUrl(wms.getLayers(), (List<String>) null, true));
