Skip to content

Commit 14a7f9e

Browse files
committed
HttpURLConnectionDownloaderService: tolerate a content type that has a charset.
Fix #666
1 parent daff82b commit 14a7f9e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main/java/ru/mystamps/web/service/HttpURLConnectionDownloaderService.java

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.util.concurrent.TimeUnit;
3030

3131
import org.apache.commons.lang3.ArrayUtils;
32+
import org.apache.commons.lang3.StringUtils;
3233

3334
import org.slf4j.Logger;
3435
import org.slf4j.LoggerFactory;
@@ -173,6 +174,10 @@ private Code validateConnection(HttpURLConnection conn) throws IOException {
173174
}
174175

175176
String contentType = conn.getContentType();
177+
178+
// We need only the first part from "text/html; charset=UTF-8"
179+
contentType = StringUtils.substringBefore(contentType, ";");
180+
176181
if (allowedContentTypes != null && !ArrayUtils.contains(allowedContentTypes, contentType)) {
177182
// TODO(security): fix possible log injection
178183
LOG.debug("Couldn't download file: unsupported file type '{}'", contentType);

0 commit comments

Comments
 (0)