You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by me...@apache.org on 2012/07/24 16:20:18 UTC
svn commit: r1365074 - in /xmlgraphics/commons/trunk:
src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java status.xml
test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java
Author: mehdi
Date: Tue Jul 24 14:20:17 2012
New Revision: 1365074
URL: http://svn.apache.org/viewvc?rev=1365074&view=rev
Log:
Bugzilla#53570: DataURIResolver does not set the systemID of the StreamSource. Submitted by Robert Meyer.
Modified:
xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java
xmlgraphics/commons/trunk/status.xml
xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java?rev=1365074&r1=1365073&r2=1365074&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/util/uri/DataURIResolver.java Tue Jul 24 14:20:17 2012
@@ -72,7 +72,7 @@ public class DataURIResolver implements
ByteArrayInputStream encodedStream = new ByteArrayInputStream(bytes);
Base64DecodeStream decodedStream = new Base64DecodeStream(
encodedStream);
- return new StreamSource(decodedStream);
+ return new StreamSource(decodedStream, href);
} else {
String encoding = "UTF-8";
final int charsetpos = header.indexOf(";charset=");
@@ -83,7 +83,7 @@ public class DataURIResolver implements
final String unescapedString = URLDecoder
.decode(data, encoding);
return new StreamSource(new java.io.StringReader(
- unescapedString));
+ unescapedString), href);
} catch (IllegalArgumentException e) {
LOG.warn(e.getMessage());
} catch (UnsupportedEncodingException e) {
Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=1365074&r1=1365073&r2=1365074&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Tue Jul 24 14:20:17 2012
@@ -41,6 +41,9 @@
</contexts>
<changes>
<release version="Trunk" date="n/a">
+ <action context="Code" dev="MH" type="fix" fixes-bug="53570" due-to="Robert Meyer">
+ Set the systemID of the StreamSource within the DataURIResolver
+ </action>
<action context="Code" dev="GA" type="fix" fixes-bug="53408" due-to="Luis Bernardo, Matthias Reischenbacher">
Add two PNG image loaders, one using internal XGC PNG code, the other using an externally supplied IDAT chunk (for raw decoding).
</action>
Modified: xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java?rev=1365074&r1=1365073&r2=1365074&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java (original)
+++ xmlgraphics/commons/trunk/test/java/org/apache/xmlgraphics/util/uri/DataURIResolverTestCase.java Tue Jul 24 14:20:17 2012
@@ -25,14 +25,19 @@ import javax.xml.transform.Source;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
-import junit.framework.TestCase;
+import org.junit.Test;
import org.apache.commons.io.IOUtils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Test case for the RFC 2397 data URL/URI resolver.
*/
-public class DataURIResolverTestCase extends TestCase {
+public class DataURIResolverTestCase {
private static final byte[] TESTDATA = new byte[] { 0, 1, 2, 3, 4, 5 };
@@ -42,6 +47,7 @@ public class DataURIResolverTestCase ext
* @throws Exception
* if an error occurs
*/
+ @Test
public void testRFC2397Generator() throws Exception {
String url = DataURLUtil.createDataURL(new ByteArrayInputStream(
TESTDATA), null);
@@ -61,6 +67,7 @@ public class DataURIResolverTestCase ext
* @throws Exception
* if an error occurs
*/
+ @Test
public void testNonMatchingContract() throws Exception {
URIResolver resolver = new DataURIResolver();
Source src;
@@ -89,6 +96,7 @@ public class DataURIResolverTestCase ext
* @throws Exception
* if an error occurs
*/
+ @Test
public void testDataURLHandling() throws Exception {
URIResolver resolver = new DataURIResolver();
actualURLHAndlingTest(resolver);
@@ -138,4 +146,17 @@ public class DataURIResolverTestCase ext
assertEquals("\u038e\u03c9\u038e", text);
}
+ /**
+ * Test that the system Id is not null for the resulting stream objects
+ * @throws Exception If an error occurs.
+ */
+ @Test
+ public void testSystemIdForNull() throws Exception {
+ URIResolver resolver = new DataURIResolver();
+ Source source = resolver.resolve("data:;base64,AAECAwQF", null);
+ assertNotNull(source.getSystemId());
+
+ source = resolver.resolve("data:text/plain;charset=iso-8859-7,%be%f9%be", null);
+ assertNotNull(source.getSystemId());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org