Prevent SVG security issues

pull/209/head
M66B 2 years ago
parent 638f9c1a22
commit 850973487a

@ -126,7 +126,9 @@ public class AdapterImage extends RecyclerView.Adapter<AdapterImage.ViewHolder>
Log.w(ex); Log.w(ex);
} }
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
!"image/svg+xml".equals(type) &&
!"svg".equals(Helper.getExtension(file.getName())))
try { try {
return ImageHelper.getScaledDrawable(context, file, type, max); return ImageHelper.getScaledDrawable(context, file, type, max);
} catch (Throwable ex) { } catch (Throwable ex) {

@ -285,6 +285,11 @@ class ImageHelper {
@NonNull @NonNull
static Bitmap renderSvg(InputStream is, int fillColor, int scaleToPixels) throws IOException { static Bitmap renderSvg(InputStream is, int fillColor, int scaleToPixels) throws IOException {
try { try {
// https://bugzilla.mozilla.org/show_bug.cgi?id=455100
// https://bug1105796.bmoattachments.org/attachment.cgi?id=8529795
// https://github.com/BigBadaboom/androidsvg/issues/122#issuecomment-361902061
SVG.setInternalEntitiesEnabled(false);
SVG svg = SVG.getFromInputStream(is); SVG svg = SVG.getFromInputStream(is);
float w = svg.getDocumentWidth(); float w = svg.getDocumentWidth();
float h = svg.getDocumentHeight(); float h = svg.getDocumentHeight();

Loading…
Cancel
Save