Changeset 6809 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-02-04T15:11:05+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r6747 r6809 26 26 import java.net.URL; 27 27 import java.net.URLDecoder; 28 import java.net.URLEncoder; 28 29 import java.util.ArrayList; 29 30 import java.util.Arrays; … … 530 531 String base64 = m.group(2); 531 532 String data = m.group(3); 532 byte[] bytes = ";base64".equals(base64) 533 ? Base64.decodeBase64(data) 534 : URLDecoder.decode(data, "utf-8").getBytes(); 533 byte[] bytes; 534 if (";base64".equals(base64)) { 535 bytes = Base64.decodeBase64(data); 536 } else { 537 try { 538 bytes = URLDecoder.decode(data, "utf-8").getBytes(); 539 } catch (IllegalArgumentException ex) { 540 Main.warn("Unable to decode URL data part: "+ex.getMessage() + " (" + data + ")"); 541 return null; 542 } 543 } 535 544 if (mediatype != null && mediatype.contains("image/svg+xml")) { 536 URI uri = getSvgUniverse().loadSVG(new StringReader(new String(bytes)), url); 537 return new ImageResource(getSvgUniverse().getDiagram(uri)); 545 String s = new String(bytes); 546 URI uri = getSvgUniverse().loadSVG(new StringReader(s), URLEncoder.encode(s, "UTF-8")); 547 SVGDiagram svg = getSvgUniverse().getDiagram(uri); 548 if (svg == null) { 549 Main.warn("Unable to process svg: "+s); 550 return null; 551 } 552 return new ImageResource(svg); 538 553 } else { 539 554 try {
Note:
See TracChangeset
for help on using the changeset viewer.