Skip to content

Commit

Permalink
Merge pull request #167 from maltalex/master
Browse files Browse the repository at this point in the history
Replaced javax.xml.bind.DatatypeConverter with java.util.Base64
  • Loading branch information
pbrant authored Nov 14, 2019
2 parents a22f47d + 59c16c2 commit 46bb75b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.xhtmlrenderer.util;

import javax.xml.bind.DatatypeConverter;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Base64;
import java.util.logging.Level;

public class FontUtil {
Expand All @@ -15,7 +15,7 @@ public static InputStream getEmbeddedBase64Data(String uri) {
int b64Index = (uri!= null)? uri.indexOf("base64,") : -1;
if (b64Index != -1) {
String b64encoded = uri.substring(b64Index + "base64,".length());
return new ByteArrayInputStream(DatatypeConverter.parseBase64Binary(b64encoded));
return new ByteArrayInputStream(Base64.getDecoder().decode(b64encoded));
} else {
XRLog.load(Level.SEVERE, "Embedded css fonts must be encoded in base 64.");
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Level;
import javax.imageio.ImageIO;
import javax.xml.bind.DatatypeConverter;

/**
* Static utility methods for working with images. Meant to suggest "best practices" for the most straightforward
Expand Down Expand Up @@ -290,7 +290,7 @@ public static byte[] getEmbeddedBase64Image(String imageDataUri) {
int b64Index = imageDataUri.indexOf("base64,");
if (b64Index != -1) {
String b64encoded = imageDataUri.substring(b64Index + "base64,".length());
return DatatypeConverter.parseBase64Binary(b64encoded);
return Base64.getDecoder().decode(b64encoded);
} else {
XRLog.load(Level.SEVERE, "Embedded XHTML images must be encoded in base 64.");
}
Expand Down

0 comments on commit 46bb75b

Please sign in to comment.