Changeset 8304 in josm for trunk/src/org/openstreetmap/josm/io/remotecontrol
- Timestamp:
- 2015-05-01T21:47:18+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/io/remotecontrol
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r8285 r8304 11 11 import java.awt.event.KeyEvent; 12 12 import java.awt.event.MouseEvent; 13 import java.io.UnsupportedEncodingException;14 import java.net.URLDecoder;15 13 import java.util.Collection; 16 14 import java.util.HashMap; … … 36 34 import org.openstreetmap.josm.gui.util.TableHelper; 37 35 import org.openstreetmap.josm.tools.GBC; 36 import org.openstreetmap.josm.tools.Utils; 38 37 39 38 /** … … 263 262 public void run() { 264 263 String[] tags = null; 265 try { 266 tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|"); 267 } catch (UnsupportedEncodingException e) { 268 throw new RuntimeException(e); 269 } 264 tags = Utils.decodeUrl(args.get("addtags")).split("\\|"); 270 265 Set<String> tagSet = new HashSet<>(); 271 266 for (String tag : tags) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadDataHandler.java
r8191 r8304 5 5 6 6 import java.io.ByteArrayInputStream; 7 import java.io.UnsupportedEncodingException;8 import java.net.URLEncoder;9 7 import java.nio.charset.StandardCharsets; 10 8 … … 62 60 @Override 63 61 public String[] getUsageExamples() { 64 try { 65 final String data = URLEncoder.encode("<osm version='0.6'><node id='-1' lat='1' lon='2' /></osm>", "UTF-8"); 66 return new String[]{ 67 "/load_data?layer_name=extra_layer&new_layer=true&data=" + data}; 68 } catch (UnsupportedEncodingException ex) { 69 throw new IllegalStateException(ex); 70 } 62 final String data = Utils.encodeUrl("<osm version='0.6'><node id='-1' lat='1' lon='2' /></osm>"); 63 return new String[]{ 64 "/load_data?layer_name=extra_layer&new_layer=true&data=" + data}; 71 65 } 72 66 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/RequestHandler.java
r8193 r8304 2 2 package org.openstreetmap.josm.io.remotecontrol.handler; 3 3 4 import org.openstreetmap.josm.Main; 5 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 6 import org.openstreetmap.josm.tools.Utils; 7 8 import javax.swing.JLabel; 9 import javax.swing.JOptionPane; 10 import java.io.UnsupportedEncodingException; 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 11 6 import java.net.URI; 12 7 import java.net.URISyntaxException; 13 import java.net.URLDecoder;14 8 import java.text.MessageFormat; 15 9 import java.util.Collections; … … 20 14 import java.util.Map; 21 15 22 import static org.openstreetmap.josm.tools.I18n.tr; 16 import javax.swing.JLabel; 17 import javax.swing.JOptionPane; 18 19 import org.openstreetmap.josm.Main; 20 import org.openstreetmap.josm.io.remotecontrol.PermissionPrefWithDefault; 21 import org.openstreetmap.josm.tools.Utils; 23 22 24 23 /** … … 210 209 } 211 210 for (String kv : uri.getRawQuery().split("&")) { 212 try { 213 final String[] kvs = URLDecoder.decode(kv, "UTF-8").split("=", 2); 214 r.put(kvs[0], kvs.length > 1 ? kvs[1] : null); 215 } catch (UnsupportedEncodingException ex) { 216 throw new IllegalStateException(ex); 217 } 211 final String[] kvs = Utils.decodeUrl(kv).split("=", 2); 212 r.put(kvs[0], kvs.length > 1 ? kvs[1] : null); 218 213 } 219 214 return r; … … 275 270 } 276 271 277 protected static String decodeParam(String param) {278 try {279 return URLDecoder.decode(param, "UTF-8");280 } catch (UnsupportedEncodingException e) {281 throw new RuntimeException(e);282 }283 }284 285 272 public void setSender(String sender) { 286 273 this.sender = sender; … … 333 320 String query = request.substring(request.indexOf('?') + 1); 334 321 if (query.indexOf("url=") == 0) { 335 args.put("url", decodeParam(query.substring(4)));322 args.put("url", Utils.decodeUrl(query.substring(4))); 336 323 } else { 337 324 int urlIdx = query.indexOf("&url="); 338 325 if (urlIdx != -1) { 339 args.put("url", decodeParam(query.substring(urlIdx + 5)));326 args.put("url", Utils.decodeUrl(query.substring(urlIdx + 5))); 340 327 query = query.substring(0, urlIdx); 341 328 } else if (query.indexOf('#') != -1) { … … 346 333 int eq = param.indexOf('='); 347 334 if (eq != -1) { 348 args.put(param.substring(0, eq), decodeParam(param.substring(eq + 1)));335 args.put(param.substring(0, eq), Utils.decodeUrl(param.substring(eq + 1))); 349 336 } 350 337 }
Note:
See TracChangeset
for help on using the changeset viewer.