Reviewers: ihab.awad,
Description:
We use commons-codec for decoding base64 and encoding hex, and java6
has equivalent functions in the standard library now.
So this removes our dependency on commons-codec
Please review this at https://codereview.appspot.com/11807044/
Affected files:
M build.xml
M src/com/google/caja/plugin/DataUriFetcher.java
M src/com/google/caja/precajole/StaticPrecajoleMap.java
D third_party/java/jakarta_commons/commons-codec-1.4.jar
Index: build.xml
===================================================================
--- build.xml (revision 5506)
+++ build.xml (working copy)
@@ -89,7 +89,6 @@
<pathelement path="${third_party}/java/guava/guava-r09.jar"/>
<pathelement path="${third_party}/java/jaf/activation.jar"/>
<pathelement
path="${third_party}/java/jakarta_commons/commons-cli.jar"/>
- <pathelement
path="${third_party}/java/jakarta_commons/commons-codec-1.4.jar"/>
<pathelement
path="${third_party}/java/jakarta_commons/commons-io-1.4.jar"/>
<pathelement path="${third_party}/java/javamail/mail.jar"/>
<pathelement path="${third_party}/java/jchardet/chardet.jar"/>
@@ -687,7 +686,6 @@
<fileset dir="${third_party}/java/jakarta_commons">
<include name="commons-cli.jar"/>
<include name="commons-io-1.4.jar"/>
- <include name="commons-codec-1.4.jar"/>
</fileset>
<fileset dir="${third_party}/java/jaf">
<include name="activation.jar"/>
@@ -1505,7 +1503,6 @@
</fileset>
<fileset dir="${third_party}/java/jakarta_commons/">
<include name="commons-io-1.4.jar" />
- <include name="commons-codec-1.4.jar" />
</fileset>
</copy>
<copy todir="${war}/WEB-INF"
Index: src/com/google/caja/plugin/DataUriFetcher.java
===================================================================
--- src/com/google/caja/plugin/DataUriFetcher.java (revision 5506)
+++ src/com/google/caja/plugin/DataUriFetcher.java (working copy)
@@ -21,9 +21,8 @@
import javax.mail.internet.ContentType;
import javax.mail.internet.ParseException;
+import javax.xml.bind.DatatypeConverter;
-import org.apache.commons.codec.binary.Base64;
-
import com.google.caja.lexer.ExternalReference;
import com.google.caja.lexer.FetchedData;
import com.google.caja.lexer.InputSource;
@@ -93,10 +92,12 @@
if (m.find()) {
try {
String charset = charsetFromMime(m.group(DATA_URI.TYPE.ordinal()));
- boolean base64 = null != m.group(DATA_URI.BASE64.ordinal());
- byte[] encoded =
m.group(DATA_URI.DATA.ordinal()).getBytes(charset);
- byte[] decoded = base64 ? new Base64().decode(encoded) : encoded;
- return decoded;
+ String data = m.group(DATA_URI.DATA.ordinal());
+ if (null != m.group(DATA_URI.BASE64.ordinal())) {
+ return DatatypeConverter.parseBase64Binary(data);
+ } else {
+ return data.getBytes(charset);
+ }
} catch (UnsupportedEncodingException e) {
throw new UriFetcher.UriFetchException(ref, mimeType, e);
}
Index: src/com/google/caja/precajole/StaticPrecajoleMap.java
===================================================================
--- src/com/google/caja/precajole/StaticPrecajoleMap.java (revision 5506)
+++ src/com/google/caja/precajole/StaticPrecajoleMap.java (working copy)
@@ -38,8 +38,9 @@
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Map;
-import org.apache.commons.codec.binary.Hex;
+import javax.xml.bind.DatatypeConverter;
+
/**
* This is a PrecajoleMap that looks up precajoled modules from a
* directory in the caja jar (or in the filesystem).
@@ -272,7 +273,7 @@
try {
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
byte[] digest = sha1.digest(s.getBytes("UTF-8"));
- return new String(Hex.encodeHex(digest));
+ return DatatypeConverter.printHexBinary(digest);
} catch (NoSuchAlgorithmException e) {
throw new SomethingWidgyHappenedError(e);
} catch (UnsupportedEncodingException e) {
Index: third_party/java/jakarta_commons/commons-codec-1.4.jar
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/java-archive
--
---
You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.