- Timestamp:
- 2014-11-26T13:50:31+01:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r7531 r7749 131 131 * Replies the list of download tasks accepting the given url. 132 132 * @param url The URL to open 133 * @param isRemotecontrol True if download request comes from remotecontrol. 133 134 * @return The list of download tasks accepting the given url. 134 135 * @since 5691 135 136 */ 136 public Collection<DownloadTask> findDownloadTasks(final String url ) {137 public Collection<DownloadTask> findDownloadTasks(final String url, boolean isRemotecontrol) { 137 138 List<DownloadTask> result = new ArrayList<>(); 138 139 for (Class<? extends DownloadTask> taskClass : downloadTasks) { … … 140 141 try { 141 142 DownloadTask task = taskClass.getConstructor().newInstance(); 142 if (task.acceptsUrl(url )) {143 if (task.acceptsUrl(url, isRemotecontrol)) { 143 144 result.add(task); 144 145 } … … 179 180 public void openUrl(boolean new_layer, final String url) { 180 181 PleaseWaitProgressMonitor monitor = new PleaseWaitProgressMonitor(tr("Download Data")); 181 Collection<DownloadTask> tasks = findDownloadTasks(url );182 Collection<DownloadTask> tasks = findDownloadTasks(url, false); 182 183 DownloadTask task = null; 183 184 Future<?> future = null; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java
r7005 r7749 68 68 69 69 // Can be overridden for more complex checking logic 70 @Override71 70 public boolean acceptsUrl(String url) { 72 71 if (url==null) return false; … … 77 76 } 78 77 return false; 78 } 79 80 /** 81 * Check / decide if the task is safe for remotecontrol. 82 * 83 * Keep in mind that a potential attacker has full control over the content 84 * of the file that will be downloaded. 85 * If it is possible to run arbitrary code or write to the local file 86 * system, then the task is (obviously) not save for remote execution. 87 * 88 * The default value is false = unsafe. Override in a subclass to 89 * allow running the task via remotecontol. 90 * 91 * @return true if it is safe to download and open any file of the 92 * corresponding format, false otherwise 93 */ 94 public boolean isSafeForRemotecontrolRequests() { 95 return false; 96 } 97 98 @Override 99 public boolean acceptsUrl(String url, boolean isRemotecontrol) { 100 if (isRemotecontrol && !isSafeForRemotecontrolRequests()) return false; 101 return acceptsUrl(url); 79 102 } 80 103 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTask.java
r7597 r7749 198 198 } 199 199 200 @Override 201 public boolean isSafeForRemotecontrolRequests() { 202 return true; 203 } 204 200 205 /** 201 206 * Determines if the given URL denotes an OSM gpx-related API call. -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTask.java
r7608 r7749 67 67 } 68 68 69 @Override 70 public boolean isSafeForRemotecontrolRequests() { 71 return true; 72 } 73 69 74 abstract class DownloadTask extends PleaseWaitRunnable { 70 75 protected OsmServerReader reader; -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r7637 r7749 169 169 } 170 170 171 @Override 172 public boolean isSafeForRemotecontrolRequests() { 173 return true; 174 } 175 171 176 /** 172 177 * Superclass of internal download task. -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadSessionTask.java
r7004 r7749 72 72 return null; 73 73 } 74 75 /** 76 * Do not allow to load a session file via remotecontrol. 77 * 78 * Session importers can be added by plugins and there is currently 79 * no way to ensure that these are safe for remotecontol. 80 * @return 81 */ 82 @Override 83 public boolean isSafeForRemotecontrolRequests() { 84 return Main.pref.getBoolean("remotecontrol.import.allow_session", false); 85 } 74 86 } -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTask.java
r6830 r7749 75 75 * Returns true if the task is able to open the given URL, false otherwise. 76 76 * @param url the url to download from 77 * @param isRemotecontrol True if download request comes from remotecontrol. 77 78 * @return True if the task is able to open the given URL, false otherwise. 79 * Return false, if the request comes from remotecontrol, but the task is not 80 * safe for remotecontrol. 81 * A task is not safe for remotecontrol if it is possible to prepare a file 82 * for download which does something unintended, e.g. gain access to the 83 * local file system. 78 84 */ 79 boolean acceptsUrl(String url );85 boolean acceptsUrl(String url, boolean isRemotecontrol); 80 86 81 87 /** -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandler.java
r7005 r7749 125 125 } 126 126 // Find download tasks for the given URL 127 suitableDownloadTasks = Main.main.menu.openLocation.findDownloadTasks(urlString );127 suitableDownloadTasks = Main.main.menu.openLocation.findDownloadTasks(urlString, true); 128 128 if (suitableDownloadTasks.isEmpty()) { 129 129 // It should maybe be better to reject the request in that case ?
Note:
See TracChangeset
for help on using the changeset viewer.