Changeset 10294 in josm
- Timestamp:
- 2016-05-29T00:14:28+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/oauth/OAuthParameters.java
r9355 r10294 2 2 package org.openstreetmap.josm.data.oauth; 3 3 4 import java.net.MalformedURLException;5 import java.net.URL;6 4 import java.util.Objects; 7 5 8 import oauth.signpost.OAuthConsumer;9 import oauth.signpost.OAuthProvider;10 6 import org.openstreetmap.josm.Main; 11 7 import org.openstreetmap.josm.data.Preferences; 12 8 import org.openstreetmap.josm.io.OsmApi; 13 9 import org.openstreetmap.josm.tools.CheckParameterUtil; 10 import org.openstreetmap.josm.tools.Utils; 11 12 import oauth.signpost.OAuthConsumer; 13 import oauth.signpost.OAuthProvider; 14 14 15 15 /** … … 52 52 final String serverUrl; 53 53 54 if (apiUrl != null) { 55 // validate URL syntax 56 try { 57 new URL(apiUrl); 58 } catch (MalformedURLException e) { 59 apiUrl = null; 60 } 54 if (!Utils.isValidUrl(apiUrl)) { 55 apiUrl = null; 61 56 } 62 57 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/UrlBasedQueryPanel.java
r10179 r10294 134 134 } 135 135 String path = url.getPath(); 136 String query = url.getQuery();137 136 if (path == null || !path.endsWith("/changesets")) 138 137 return null; 139 138 140 139 try { 141 return ChangesetQuery.buildFromUrlQuery( query);140 return ChangesetQuery.buildFromUrlQuery(url.getQuery()); 142 141 } catch (ChangesetQueryUrlException e) { 143 142 Main.warn(e.getMessage()); -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r10217 r10294 14 14 import java.awt.event.ItemEvent; 15 15 import java.awt.event.ItemListener; 16 import java.net.MalformedURLException;17 import java.net.URL;18 16 import java.util.Arrays; 19 17 … … 258 256 if (getComponent().getText().trim().isEmpty()) 259 257 return false; 260 261 try { 262 new URL(getComponent().getText().trim()); 263 return true; 264 } catch (MalformedURLException e) { 265 return false; 266 } 258 return Utils.isValidUrl(getComponent().getText().trim()); 267 259 } 268 260 -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r10212 r10294 12 12 import java.lang.reflect.Constructor; 13 13 import java.lang.reflect.InvocationTargetException; 14 import java.net.MalformedURLException;15 14 import java.net.URL; 16 15 import java.text.MessageFormat; … … 206 205 s = attr.getValue("Plugin-Link"); 207 206 } 208 if (s != null) { 209 try { 210 new URL(s); 211 } catch (MalformedURLException e) { 212 Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name)); 213 s = null; 214 } 207 if (s != null && !Utils.isValidUrl(s)) { 208 Main.info(tr("Invalid URL ''{0}'' in plugin {1}", s, name)); 209 s = null; 215 210 } 216 211 link = s; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r10289 r10294 1324 1324 1325 1325 /** 1326 * Determines if the given URL is valid. 1327 * @param url The URL to test 1328 * @return {@code true} if the url is valid 1329 * @since 10294 1330 */ 1331 public static boolean isValidUrl(String url) { 1332 try { 1333 new URL(url); 1334 return true; 1335 } catch (MalformedURLException | NullPointerException e) { 1336 return false; 1337 } 1338 } 1339 1340 /** 1326 1341 * Creates a new {@link ThreadFactory} which creates threads with names according to {@code nameFormat}. 1327 1342 * @param nameFormat a {@link String#format(String, Object...)} compatible name format; its first argument is a unique thread index
Note:
See TracChangeset
for help on using the changeset viewer.