mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-02-04 12:15:30 +00:00
SPARK-2380: insertPicture(): Check if the file extension is a known image type
This commit is contained in:
committed by
Guus der Kinderen
parent
ef36f0ac6e
commit
cd011e6ce4
@ -33,6 +33,7 @@ import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.URI;
|
||||
import java.net.URLConnection;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
@ -386,6 +387,11 @@ public class MessageEntry extends TimeStampedEntry
|
||||
if (path == null || path.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
// Check if the file extension is a known image type
|
||||
String mimeType = URLConnection.getFileNameMap().getContentTypeFor(path);
|
||||
if (mimeType == null || !mimeType.startsWith("image/")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try (final CloseableHttpClient httpClient =
|
||||
HttpClients.custom()
|
||||
|
||||
Reference in New Issue
Block a user