Skip to content

Commit 7a45624

Browse files
author
RTLcoil
authored
Detect data URLs with suffix in mime type (#213)
1 parent af1d740 commit 7a45624

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

cloudinary-core/src/main/java/com/cloudinary/utils/StringUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public static String read(InputStream in) throws IOException {
209209
}
210210

211211
public static boolean isRemoteUrl(String file) {
212-
return file.matches("ftp:.*|https?:.*|s3:.*|gs:.*|data:([\\w-]+/[\\w-]+)?(;[\\w-]+=[\\w-]+)*;base64,([a-zA-Z0-9/+\n=]+)");
212+
return file.matches("ftp:.*|https?:.*|s3:.*|gs:.*|data:([\\w-]+/[\\w-]+(\\+[\\w-]+)?)?(;[\\w-]+=[\\w-]+)*;base64,([a-zA-Z0-9/+\n=]+)");
213213
}
214214

215215
/**

cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractUploaderTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ public void testIsRemoteUrl() {
137137
"gs://cloudinary/images/old_logo.png",
138138
"data:image/gif;charset=utf8;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
139139
"data:image/gif;param1=value1;param2=value2;base64," +
140-
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"};
140+
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
141+
"data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg"};
141142

142143
for (String url : urls) {
143144
assertTrue(isRemoteUrl(url));

0 commit comments

Comments
 (0)