Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue with embedded svg images added like data-URL (#1604) #1605

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public String onDocImage(IImage image, Object context) {
public String onURLImage(IImage image, Object context) {
assert (image != null);
String uri = image.getID();
if (uri.startsWith("http:") || uri.startsWith("https:")) {
if (uri.startsWith("http:") || uri.startsWith("https:") || uri.startsWith("data:")) {
return uri;
}
return handleImage(image, context, "uri", true); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public class FileUtil {
* The <code>HashMap</code> object that stores image type/file extension
* mapping.
*/
private static HashMap fileExtension = new HashMap();
private static HashMap mimeType = new HashMap();
private static HashMap<String, String> fileExtension = new HashMap<String, String>();
private static HashMap<String, String> mimeType = new HashMap<String, String>();

static {
// initialize fileExtension
Expand Down Expand Up @@ -183,7 +183,7 @@ public static String getExtFromFileName(String fileName) {
* resource.
*/
public static boolean isLocalResource(String uri) {
return uri != null && uri.length() > 0 && !uri.toLowerCase().startsWith("http"); //$NON-NLS-1$
return uri != null && uri.length() > 0 && !uri.toLowerCase().startsWith("http") && !uri.toLowerCase().startsWith("data"); //$NON-NLS-1$
}

/**
Expand Down Expand Up @@ -264,17 +264,17 @@ public static boolean saveFile(File targetFile, byte[] data) {
* @return File extension string say, ".jpg".
*/
public static String getExtFromType(String fileType) {
return (String) fileExtension.get(fileType);
return fileExtension.get(fileType);
}

/**
* Gets the Image file mime type according to the given file extension.
*
* @param fileType The image file type say, ".jpg".
* @param imgExt The image file type say, ".jpg".
* @return File extension string say, "image/jpg".
*/
public static String getTypeFromExt(String imgExt) {
return (String) mimeType.get(imgExt);
return mimeType.get(imgExt);
}

/**
Expand Down Expand Up @@ -346,6 +346,11 @@ public static byte[] getFileContent(String fileName) {
return null;
}

/**
* Delete the directory content
*
* @param file name of the directory
*/
public static void deleteDir(File file) {
if (file.isDirectory()) {
String[] list = file.list();
Expand All @@ -358,6 +363,11 @@ public static void deleteDir(File file) {
file.delete();
}

/**
* Get the java directory of temporary files
*
* @return Return the java directory of temporary files
*/
public static String getJavaTmpDir() {
return System.getProperty("java.io.tmpdir");
}
Expand Down
Loading