Changeset 8304 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2015-05-01T21:47:18+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/SearchNotesDownloadAction.java
r8196 r8304 7 7 import java.awt.GridBagLayout; 8 8 import java.awt.event.ActionEvent; 9 import java.io.UnsupportedEncodingException;10 import java.net.URLEncoder;11 9 import java.util.Collections; 12 10 import java.util.LinkedList; … … 23 21 import org.openstreetmap.josm.gui.widgets.HistoryComboBox; 24 22 import org.openstreetmap.josm.io.OsmApi; 23 import org.openstreetmap.josm.tools.Utils; 25 24 26 25 /** … … 98 97 sb.append(closedLimit); 99 98 sb.append("&q="); 100 try { 101 sb.append(URLEncoder.encode(searchTerm, "UTF-8")); 102 } catch (UnsupportedEncodingException ex) { 103 Main.error(ex, true); // thrown if UTF-8 isn't supported which seems unlikely. 104 return; 105 } 99 sb.append(Utils.encodeUrl(searchTerm)); 106 100 107 101 new DownloadNotesTask().loadUrl(false, sb.toString(), null); -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r7771 r8304 9 9 import java.awt.event.MouseAdapter; 10 10 import java.awt.event.MouseEvent; 11 import java.io.UnsupportedEncodingException;12 import java.net.URLEncoder;13 11 import java.text.NumberFormat; 14 12 import java.util.ArrayList; … … 25 23 26 24 import javax.swing.AbstractAction; 27 import javax.swing.JOptionPane;28 25 import javax.swing.JTable; 29 26 import javax.swing.ListSelectionModel; … … 46 43 import org.openstreetmap.josm.tools.OpenBrowser; 47 44 import org.openstreetmap.josm.tools.Shortcut; 45 import org.openstreetmap.josm.tools.Utils; 48 46 49 47 /** … … 62 60 private ShowUserInfoAction showUserInfoAction; 63 61 62 /** 63 * Constructs a new {@code UserListDialog}. 64 */ 64 65 public UserListDialog() { 65 66 super(tr("Authors"), "userlist", tr("Open a list of people working on the selected objects."), 66 67 Shortcut.registerShortcut("subwindow:authors", tr("Toggle: {0}", tr("Authors")), KeyEvent.VK_A, Shortcut.ALT_SHIFT), 150); 67 68 68 build(); 69 69 } … … 221 221 protected String createInfoUrl(Object infoObject) { 222 222 User user = (User)infoObject; 223 try { 224 return Main.getBaseUserUrl() + "/" + URLEncoder.encode(user.getName(), "UTF-8").replaceAll("\\+", "%20"); 225 } catch(UnsupportedEncodingException e) { 226 Main.error(e); 227 JOptionPane.showMessageDialog( 228 Main.parent, 229 tr("<html>Failed to create an URL because the encoding ''{0}''<br>" 230 + "was missing on this system.</html>", "UTF-8"), 231 tr("Missing encoding"), 232 JOptionPane.ERROR_MESSAGE 233 ); 234 return null; 235 } 223 return Main.getBaseUserUrl() + "/" + Utils.encodeUrl(user.getName()).replaceAll("\\+", "%20"); 236 224 } 237 225 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r8285 r8304 14 14 import java.awt.event.MouseAdapter; 15 15 import java.awt.event.MouseEvent; 16 import java.io.UnsupportedEncodingException;17 16 import java.net.HttpURLConnection; 18 17 import java.net.URI; 19 18 import java.net.URISyntaxException; 20 import java.net.URLEncoder;21 19 import java.util.ArrayList; 22 20 import java.util.Arrays; … … 1073 1071 if (tagTable.getSelectedRowCount() == 1) { 1074 1072 row = tagTable.getSelectedRow(); 1075 String key = U RLEncoder.encode(tagData.getValueAt(row, 0).toString(), "UTF-8");1073 String key = Utils.encodeUrl(tagData.getValueAt(row, 0).toString()); 1076 1074 @SuppressWarnings("unchecked") 1077 1075 Map<String, Integer> m = (Map<String, Integer>) tagData.getValueAt(row, 1); 1078 String val = U RLEncoder.encode(m.entrySet().iterator().next().getKey(), "UTF-8");1076 String val = Utils.encodeUrl(m.entrySet().iterator().next().getKey()); 1079 1077 1080 1078 uris.add(new URI(String.format("%s%sTag:%s=%s", base, lang, key, val))); … … 1088 1086 String type = ((Relation)membershipData.getValueAt(row, 0)).get("type"); 1089 1087 if (type != null) { 1090 type = U RLEncoder.encode(type, "UTF-8");1088 type = Utils.encodeUrl(type); 1091 1089 } 1092 1090 … … 1149 1147 } 1150 1148 }); 1151 } catch (URISyntaxException | UnsupportedEncodingExceptione1) {1149 } catch (URISyntaxException e1) { 1152 1150 Main.error(e1); 1153 1151 } -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r8287 r8304 364 364 @Override 365 365 protected void realRun() throws SAXException, IOException, OsmTransferException { 366 String urlString = useserver.url+ java.net.URLEncoder.encode(searchExpression, "UTF-8");366 String urlString = useserver.url+Utils.encodeUrl(searchExpression); 367 367 368 368 try { -
trunk/src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java
r8291 r8304 11 11 import java.awt.Insets; 12 12 import java.awt.event.ActionEvent; 13 import java.io.UnsupportedEncodingException;14 import java.net.URLEncoder;15 13 import java.text.DateFormat; 16 14 import java.util.Collections; … … 185 183 } 186 184 187 protected static String getUserUrl(String username) throws UnsupportedEncodingException{188 return Main.getBaseUserUrl() + "/" + U RLEncoder.encode(username, "UTF-8").replaceAll("\\+", "%20");185 protected static String getUserUrl(String username) { 186 return Main.getBaseUserUrl() + "/" + Utils.encodeUrl(username).replaceAll("\\+", "%20"); 189 187 } 190 188 … … 209 207 } 210 208 lblUser.setDescription(username); 211 try { 212 if (user != null && user != User.getAnonymous()) { 213 lblUser.setUrl(getUserUrl(username)); 214 } else { 215 lblUser.setUrl(null); 216 } 217 } catch(UnsupportedEncodingException e) { 218 Main.error(e); 209 if (user != null && user != User.getAnonymous()) { 210 lblUser.setUrl(getUserUrl(username)); 211 } else { 219 212 lblUser.setUrl(null); 220 213 } … … 226 219 } else { 227 220 lblUser.setDescription(username); 228 try { 229 lblUser.setUrl(getUserUrl(username)); 230 } catch(UnsupportedEncodingException e) { 231 Main.error(e); 232 lblUser.setUrl(null); 233 } 221 lblUser.setUrl(getUserUrl(username)); 234 222 } 235 223 lblChangeset.setDescription(tr("none")); -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r8256 r8304 3 3 4 4 import java.awt.Color; 5 import java.io.UnsupportedEncodingException;6 5 import java.lang.annotation.ElementType; 7 6 import java.lang.annotation.Retention; … … 11 10 import java.lang.reflect.InvocationTargetException; 12 11 import java.lang.reflect.Method; 13 import java.net.URLEncoder;14 12 import java.nio.charset.StandardCharsets; 15 13 import java.util.ArrayList; … … 801 799 */ 802 800 public static String URL_encode(String s) { 803 try { 804 return s == null ? null : URLEncoder.encode(s, "UTF-8"); 805 } catch (UnsupportedEncodingException ex) { 806 throw new RuntimeException(ex); 807 } 801 return s == null ? null : Utils.encodeUrl(s); 808 802 } 809 803 -
trunk/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
r8291 r8304 9 9 import java.io.InputStream; 10 10 import java.io.InputStreamReader; 11 import java.io.UnsupportedEncodingException;12 11 import java.lang.reflect.Field; 13 12 import java.net.HttpURLConnection; 14 13 import java.net.MalformedURLException; 15 14 import java.net.URL; 16 import java.net.URLEncoder;17 15 import java.nio.charset.StandardCharsets; 18 16 import java.util.HashMap; … … 251 249 252 250 protected String buildPostRequest(Map<String,String> parameters) throws OsmOAuthAuthorizationException { 253 try { 254 StringBuilder sb = new StringBuilder(); 255 256 for(Iterator<Entry<String,String>> it = parameters.entrySet().iterator(); it.hasNext();) { 257 Entry<String,String> entry = it.next(); 258 String value = entry.getValue(); 259 value = (value == null) ? "" : value; 260 sb.append(entry.getKey()).append("=").append(URLEncoder.encode(value, "UTF-8")); 261 if (it.hasNext()) { 262 sb.append("&"); 263 } 264 } 265 return sb.toString(); 266 } catch(UnsupportedEncodingException e) { 267 throw new OsmOAuthAuthorizationException(e); 268 } 251 StringBuilder sb = new StringBuilder(); 252 253 for(Iterator<Entry<String,String>> it = parameters.entrySet().iterator(); it.hasNext();) { 254 Entry<String,String> entry = it.next(); 255 String value = entry.getValue(); 256 value = (value == null) ? "" : value; 257 sb.append(entry.getKey()).append("=").append(Utils.encodeUrl(value)); 258 if (it.hasNext()) { 259 sb.append("&"); 260 } 261 } 262 return sb.toString(); 269 263 } 270 264 -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r8291 r8304 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.UnsupportedEncodingException;7 import java.net.URLEncoder;8 6 import java.text.DateFormat; 9 7 import java.text.MessageFormat; … … 18 16 import java.util.Map.Entry; 19 17 20 import org.openstreetmap.josm.Main;21 18 import org.openstreetmap.josm.data.Bounds; 22 19 import org.openstreetmap.josm.data.coor.LatLon; … … 258 255 sb.append("user").append("=").append(uid); 259 256 } else if (userName != null) { 260 try { 261 sb.append("display_name").append("=").append(URLEncoder.encode(userName, "UTF-8")); 262 } catch (UnsupportedEncodingException e) { 263 Main.error(e); 264 } 257 sb.append("display_name").append("=").append(Utils.encodeUrl(userName)); 265 258 } 266 259 if (bounds != null) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r8291 r8304 15 15 import java.io.StringReader; 16 16 import java.io.StringWriter; 17 import java.io.UnsupportedEncodingException;18 17 import java.net.ConnectException; 19 18 import java.net.HttpURLConnection; … … 21 20 import java.net.SocketTimeoutException; 22 21 import java.net.URL; 23 import java.net.URLEncoder;24 22 import java.nio.charset.StandardCharsets; 25 23 import java.util.Collection; … … 815 813 .append(latlon.lon()) 816 814 .append("&text=") 817 .append( urlEncode(text)).toString();815 .append(Utils.encodeUrl(text)).toString(); 818 816 819 817 String response = sendRequest("POST", noteUrl, null, monitor, true, false); … … 833 831 String noteUrl = noteStringBuilder(note) 834 832 .append("/comment?text=") 835 .append( urlEncode(comment)).toString();833 .append(Utils.encodeUrl(comment)).toString(); 836 834 837 835 String response = sendRequest("POST", noteUrl, null, monitor, true, false); … … 849 847 public Note closeNote(Note note, String closeMessage, ProgressMonitor monitor) throws OsmTransferException { 850 848 initialize(monitor); 851 String encodedMessage = urlEncode(closeMessage);849 String encodedMessage = Utils.encodeUrl(closeMessage); 852 850 StringBuilder urlBuilder = noteStringBuilder(note) 853 851 .append("/close"); … … 871 869 public Note reopenNote(Note note, String reactivateMessage, ProgressMonitor monitor) throws OsmTransferException { 872 870 initialize(monitor); 873 String encodedMessage = urlEncode(reactivateMessage);871 String encodedMessage = Utils.encodeUrl(reactivateMessage); 874 872 StringBuilder urlBuilder = noteStringBuilder(note) 875 873 .append("/reopen"); … … 897 895 } 898 896 } 899 900 /** URL encodes a string. Useful for transforming user input into URL query strings*/901 private String urlEncode(String string) throws OsmTransferException {902 try {903 return URLEncoder.encode(string, "UTF-8");904 } catch (UnsupportedEncodingException e) {905 Main.error(e, true);906 throw new OsmTransferException(tr("Error encoding string: {0}", string), e);907 }908 }909 897 } -
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 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r8286 r8304 27 27 import java.io.InputStream; 28 28 import java.io.StringReader; 29 import java.io.UnsupportedEncodingException;30 29 import java.net.URI; 31 30 import java.net.URL; 32 import java.net.URLDecoder;33 import java.net.URLEncoder;34 31 import java.nio.charset.StandardCharsets; 35 32 import java.util.ArrayList; … … 287 284 * 288 285 * (optional) 286 * @param archive zip file where the image is located 289 287 * @return the current object, for convenience 290 288 */ … … 816 814 */ 817 815 private static ImageResource getIfAvailableDataUrl(String url) { 818 try { 819 Matcher m = dataUrlPattern.matcher(url); 820 if (m.matches()) { 821 String mediatype = m.group(1); 822 String base64 = m.group(2); 823 String data = m.group(3); 824 byte[] bytes; 825 if (";base64".equals(base64)) { 826 bytes = DatatypeConverter.parseBase64Binary(data); 827 } else { 828 try { 829 bytes = URLDecoder.decode(data, "UTF-8").getBytes(StandardCharsets.UTF_8); 830 } catch (IllegalArgumentException ex) { 831 Main.warn("Unable to decode URL data part: "+ex.getMessage() + " (" + data + ")"); 832 return null; 833 } 834 } 835 if ("image/svg+xml".equals(mediatype)) { 836 String s = new String(bytes, StandardCharsets.UTF_8); 837 SVGDiagram svg = null; 838 synchronized (getSvgUniverse()) { 839 URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8")); 840 svg = getSvgUniverse().getDiagram(uri); 841 } 842 if (svg == null) { 843 Main.warn("Unable to process svg: "+s); 844 return null; 845 } 846 return new ImageResource(svg); 847 } else { 848 try { 849 // See #10479: for PNG files, always enforce transparency to be sure tNRS chunk is used even not in paletted mode 850 // This can be removed if someday Oracle fixes https://bugs.openjdk.java.net/browse/JDK-6788458 851 // hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/828c4fedd29f/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656 852 Image img = read(new ByteArrayInputStream(bytes), false, true); 853 return img == null ? null : new ImageResource(img); 854 } catch (IOException e) { 855 Main.warn("IOException while reading image: "+e.getMessage()); 856 } 857 } 858 } 859 return null; 860 } catch (UnsupportedEncodingException ex) { 861 throw new RuntimeException(ex.getMessage(), ex); 862 } 816 Matcher m = dataUrlPattern.matcher(url); 817 if (m.matches()) { 818 String mediatype = m.group(1); 819 String base64 = m.group(2); 820 String data = m.group(3); 821 byte[] bytes; 822 if (";base64".equals(base64)) { 823 bytes = DatatypeConverter.parseBase64Binary(data); 824 } else { 825 try { 826 bytes = Utils.decodeUrl(data).getBytes(StandardCharsets.UTF_8); 827 } catch (IllegalArgumentException ex) { 828 Main.warn("Unable to decode URL data part: "+ex.getMessage() + " (" + data + ")"); 829 return null; 830 } 831 } 832 if ("image/svg+xml".equals(mediatype)) { 833 String s = new String(bytes, StandardCharsets.UTF_8); 834 SVGDiagram svg = null; 835 synchronized (getSvgUniverse()) { 836 URI uri = getSvgUniverse().loadSVG(new StringReader(s), Utils.encodeUrl(s)); 837 svg = getSvgUniverse().getDiagram(uri); 838 } 839 if (svg == null) { 840 Main.warn("Unable to process svg: "+s); 841 return null; 842 } 843 return new ImageResource(svg); 844 } else { 845 try { 846 // See #10479: for PNG files, always enforce transparency to be sure tNRS chunk is used even not in paletted mode 847 // This can be removed if someday Oracle fixes https://bugs.openjdk.java.net/browse/JDK-6788458 848 // hg.openjdk.java.net/jdk7u/jdk7u/jdk/file/828c4fedd29f/src/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java#l656 849 Image img = read(new ByteArrayInputStream(bytes), false, true); 850 return img == null ? null : new ImageResource(img); 851 } catch (IOException e) { 852 Main.warn("IOException while reading image: "+e.getMessage()); 853 } 854 } 855 } 856 return null; 863 857 } 864 858 -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r8291 r8304 6 6 import java.awt.HeadlessException; 7 7 import java.awt.Toolkit; 8 import java.io.UnsupportedEncodingException;9 import java.net.URLDecoder;10 8 import java.util.HashMap; 11 9 import java.util.Map; … … 26 24 // a percent sign indicates an encoded URL (RFC 1738). 27 25 if (url.contains("%")) { 28 url = U RLDecoder.decode(url, "UTF-8");29 } 30 } catch ( UnsupportedEncodingException |IllegalArgumentException x) {26 url = Utils.decodeUrl(url); 27 } 28 } catch (IllegalArgumentException x) { 31 29 Main.error(x); 32 30 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r8291 r8304 25 25 import java.net.URL; 26 26 import java.net.URLConnection; 27 import java.net.URLDecoder; 27 28 import java.net.URLEncoder; 28 29 import java.nio.charset.StandardCharsets; … … 1116 1117 sb.append(c); 1117 1118 } else { 1118 try { 1119 sb.append(URLEncoder.encode(c, "UTF-8")); 1120 } catch (UnsupportedEncodingException ex) { 1121 throw new RuntimeException(ex); 1122 } 1119 sb.append(encodeUrl(c)); 1123 1120 } 1124 1121 } 1125 1122 return sb.toString(); 1123 } 1124 1125 /** 1126 * Translates a string into <code>application/x-www-form-urlencoded</code> 1127 * format. This method uses UTF-8 encoding scheme to obtain the bytes for unsafe 1128 * characters. 1129 * 1130 * @param s <code>String</code> to be translated. 1131 * @return the translated <code>String</code>. 1132 * @see #decodeUrl(String) 1133 * @since 8304 1134 */ 1135 public static String encodeUrl(String s) { 1136 final String enc = StandardCharsets.UTF_8.name(); 1137 try { 1138 return URLEncoder.encode(s, enc); 1139 } catch (UnsupportedEncodingException e) { 1140 Main.error(e); 1141 return null; 1142 } 1143 } 1144 1145 /** 1146 * Decodes a <code>application/x-www-form-urlencoded</code> string. 1147 * UTF-8 encoding is used to determine 1148 * what characters are represented by any consecutive sequences of the 1149 * form "<code>%<i>xy</i></code>". 1150 * 1151 * @param s the <code>String</code> to decode 1152 * @return the newly decoded <code>String</code> 1153 * @see #encodeUrl(String) 1154 * @since 8304 1155 */ 1156 public static String decodeUrl(String s) { 1157 final String enc = StandardCharsets.UTF_8.name(); 1158 try { 1159 return URLDecoder.decode(s, enc); 1160 } catch (UnsupportedEncodingException e) { 1161 Main.error(e); 1162 return null; 1163 } 1126 1164 } 1127 1165
Note:
See TracChangeset
for help on using the changeset viewer.