Changeset 6809 in josm
- Timestamp:
- 2014-02-04T15:11:05+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r6806 r6809 27 27 import org.openstreetmap.josm.gui.mappaint.Cascade; 28 28 import org.openstreetmap.josm.gui.mappaint.Environment; 29 import org.openstreetmap.josm.io.XmlWriter; 29 30 import org.openstreetmap.josm.tools.ColorHelper; 30 31 import org.openstreetmap.josm.tools.Utils; … … 541 542 } 542 543 } 544 545 /** 546 * XML-encode a string. 547 * 548 * Escapes special characters in xml. Alternative to using <![CDATA[ ... ]]> 549 * blocks. 550 * @param s arbitrary string 551 * @return the encoded string 552 */ 553 public static String XML_encode(String s) { 554 return s == null ? null : XmlWriter.encode(s); 555 } 543 556 } 544 557 -
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.