Changeset 14496 in josm


Ignore:
Timestamp:
2018-12-02T18:35:04+01:00 (7 weeks ago)
Author:
Don-vip
Message:

fix #17060, see #16073 - Support Internationalized domain names (IDN)

This allows JOSM to accesss https://öpnvkarte.de

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java

    r14298 r14496  
    20112011     */
    20122012    // Needed by UrlValidator
    2013     static String unicodeToASCII(String input) {
     2013    public static String unicodeToASCII(String input) {
    20142014        if (isOnlyASCII(input)) { // skip possibly expensive processing
    20152015            return input;
  • trunk/src/org/openstreetmap/josm/tools/HttpClient.java

    r14214 r14496  
    1313import java.net.CookieManager;
    1414import java.net.HttpURLConnection;
     15import java.net.MalformedURLException;
    1516import java.net.URL;
    1617import java.nio.charset.StandardCharsets;
     
    3031
    3132import org.openstreetmap.josm.data.Version;
     33import org.openstreetmap.josm.data.validation.routines.DomainValidator;
    3234import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3335import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    7880
    7981    private HttpClient(URL url, String requestMethod) {
    80         this.url = url;
     82        try {
     83            String host = url.getHost();
     84            String asciiHost = DomainValidator.unicodeToASCII(host);
     85            this.url = asciiHost.equals(host) ? url : new URL(url.getProtocol(), asciiHost, url.getPort(), url.getFile());
     86        } catch (MalformedURLException e) {
     87            throw new JosmRuntimeException(e);
     88        }
    8189        this.requestMethod = requestMethod;
    8290        this.headers.put("Accept-Encoding", "gzip");
Note: See TracChangeset for help on using the changeset viewer.