Skip to content

Commit 4265235

Browse files
committed
HttpURLConnectionDownloaderService: don't check file for emptiness and pass it along to validators.
Correction for 874d709
1 parent 874d709 commit 4265235

File tree

4 files changed

+0
-14
lines changed

4 files changed

+0
-14
lines changed

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

-11
Original file line numberDiff line numberDiff line change
@@ -184,17 +184,6 @@ private Code validateConnection(HttpURLConnection conn) throws IOException {
184184
return Code.INVALID_FILE_TYPE;
185185
}
186186

187-
// TODO: add protection against huge files
188-
// When the content length is not known, methods returns -1. It also happens for gzipped
189-
// response. In this case, we allow to download a file and relies to a form validation
190-
// that will take place later.
191-
int contentLength = conn.getContentLength();
192-
if (contentLength == 0) {
193-
// TODO(security): fix possible log injection
194-
LOG.debug("Couldn't download file: invalid Content-Length: {}", contentLength);
195-
return Code.INVALID_FILE_SIZE;
196-
}
197-
198187
return Code.SUCCESS;
199188
}
200189

src/main/java/ru/mystamps/web/service/dto/DownloadResult.java

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ public enum Code {
4848
INVALID_URL,
4949
INVALID_REDIRECT,
5050
INVALID_FILE_TYPE,
51-
INVALID_FILE_SIZE,
5251
FILE_NOT_FOUND,
5352
INSUFFICIENT_PERMISSIONS,
5453
UNEXPECTED_ERROR,

src/main/resources/ru/mystamps/i18n/ValidationMessages.properties

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ru.mystamps.web.support.beanvalidation.RequireImageOrImageUrl.message = Image or
2828
ru.mystamps.web.service.dto.DownloadResult.INVALID_URL = Invalid URL
2929
ru.mystamps.web.service.dto.DownloadResult.INVALID_REDIRECT = URL must not redirect to another address
3030
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_TYPE = Invalid file type
31-
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_SIZE = Invalid file size
3231
ru.mystamps.web.service.dto.DownloadResult.FILE_NOT_FOUND = File not found
3332
ru.mystamps.web.service.dto.DownloadResult.UNEXPECTED_ERROR = Could not download file
3433

src/main/resources/ru/mystamps/i18n/ValidationMessages_ru.properties

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ru.mystamps.web.support.beanvalidation.RequireImageOrImageUrl.message = Необ
2828
ru.mystamps.web.service.dto.DownloadResult.INVALID_URL = Неправильный URL
2929
ru.mystamps.web.service.dto.DownloadResult.INVALID_REDIRECT = URL не должен перенаправлять на другой адрес
3030
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_TYPE = Недопустимый тип файла
31-
ru.mystamps.web.service.dto.DownloadResult.INVALID_FILE_SIZE = Недопустимый размер файла
3231
ru.mystamps.web.service.dto.DownloadResult.FILE_NOT_FOUND = Файл не найден
3332
ru.mystamps.web.service.dto.DownloadResult.UNEXPECTED_ERROR = Не удалось скачать файл
3433

0 commit comments

Comments
 (0)