Changeset 12937 in josm for trunk/src


Ignore:
Timestamp:
2017-10-07T22:39:09+02:00 (7 years ago)
Author:
Don-vip
Message:

fix #14961 - catch IAE when decoding base64 data

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/protocols/data/DataConnection.java

    r10931 r12937  
    88import java.net.URLConnection;
    99import java.util.Base64;
     10
     11import org.openstreetmap.josm.tools.bugreport.BugReport;
    1012
    1113/**
     
    3234    @Override
    3335    public InputStream getInputStream() throws IOException {
    34         return new ByteArrayInputStream(Base64.getDecoder().decode(url.toString().replaceFirst("^.*;base64,", "")));
     36        try {
     37            return new ByteArrayInputStream(Base64.getDecoder().decode(url.toString().replaceFirst("^.*;base64,", "")));
     38        } catch (IllegalArgumentException e) {
     39            throw BugReport.intercept(e).put("url", url);
     40        }
    3541    }
    3642}
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r12870 r12937  
    977977            String data = m.group(3);
    978978            byte[] bytes;
    979             if (";base64".equals(base64)) {
    980                 bytes = Base64.getDecoder().decode(data);
    981             } else {
    982                 try {
     979            try {
     980                if (";base64".equals(base64)) {
     981                    bytes = Base64.getDecoder().decode(data);
     982                } else {
    983983                    bytes = Utils.decodeUrl(data).getBytes(StandardCharsets.UTF_8);
    984                 } catch (IllegalArgumentException ex) {
    985                     Logging.log(Logging.LEVEL_WARN, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')', ex);
    986                     return null;
    987                 }
     984                }
     985            } catch (IllegalArgumentException ex) {
     986                Logging.log(Logging.LEVEL_WARN, "Unable to decode URL data part: "+ex.getMessage() + " (" + data + ')', ex);
     987                return null;
    988988            }
    989989            String mediatype = m.group(1);
Note: See TracChangeset for help on using the changeset viewer.