Ignore:
Timestamp:
2014-01-01T14:26:21+01:00 (11 years ago)
Author:
simon04
Message:

JOSM/mirrored_download: apply URL encoding hack which has been removed from core (see #josm8566)

Location:
applications/editors/josm/plugins/mirrored_download
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/mirrored_download/build.xml

    r29854 r30162  
    55    <property name="commit.message" value=""/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="6162"/>
     7    <property name="plugin.main.version" value="6589"/>
    88
    99    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/mirrored_download/src/mirrored_download/MirroredDownloadAction.java

    r30106 r30162  
    5656            dialog.rememberSettings();
    5757            Bounds area = dialog.getSelectedDownloadArea();
    58             DownloadOsmTask task = new DownloadOsmTask();
     58            DownloadOsmTask task = new DownloadOsmTask() {
     59
     60                protected final String encodePartialUrl(String url, String safePart) {
     61                    if (url != null && safePart != null) {
     62                        int pos = url.indexOf(safePart);
     63                        if (pos > -1) {
     64                            pos += safePart.length();
     65                            try {
     66                                return url.substring(0, pos) + URLEncoder.encode(url.substring(pos), "UTF-8").replaceAll("\\+", "%20");
     67                            } catch (UnsupportedEncodingException e) {
     68                                e.printStackTrace();
     69                            }
     70                        }
     71                    }
     72                    return url;
     73                }
     74
     75                @Override
     76                protected String modifyUrlBeforeLoad(String url) {
     77                    if (url.matches(PATTERN_OVERPASS_API_URL)) {
     78                        return encodePartialUrl(url, "/interpreter?data="); // encode only the part after the = sign
     79                    } else if (url.matches(PATTERN_OVERPASS_API_XAPI_URL)) {
     80                        return encodePartialUrl(url, "/xapi?"); // encode only the part after the ? sign
     81                    } else {
     82                        return url;
     83                    }
     84                }
     85
     86            };
    5987            Future<?> future = task.download(
    6088                    new MirroredDownloadReader(area, dialog.getOverpassType(), dialog.getOverpassQuery()),
Note: See TracChangeset for help on using the changeset viewer.