diff --git a/src/main/java/org/verapdf/rest/resources/ValidateResource.java b/src/main/java/org/verapdf/rest/resources/ValidateResource.java index e63cdca..bf6d75a 100644 --- a/src/main/java/org/verapdf/rest/resources/ValidateResource.java +++ b/src/main/java/org/verapdf/rest/resources/ValidateResource.java @@ -208,7 +208,7 @@ private static InputStream validate(InputStream uploadedInputStream, String file private static SeekableInputStream createInputStream(InputStream uploadedInputStream, String sha1Hex, Integer fileSize) { InputStream inputStream = uploadedInputStream; - if (sha1Hex != null) { + if (sha1Hex != null && !sha1Hex.isEmpty()) { MessageDigest sha1 = getDigest(); inputStream = new DigestInputStream(uploadedInputStream, sha1); } @@ -219,7 +219,7 @@ private static SeekableInputStream createInputStream(InputStream uploadedInputSt try { SeekableInputStream seekableInputStream = SeekableInputStream.getSeekableStream(inputStream, CONVERTER_MB_TO_B * maxFileSize); - if (sha1Hex != null && !sha1Hex.equalsIgnoreCase( + if (sha1Hex != null && !sha1Hex.isEmpty() && !sha1Hex.equalsIgnoreCase( Hex.encodeHexString(((DigestInputStream) inputStream).getMessageDigest().digest()))) { throw new BadRequestException(String.format( "Calculated SHA1 value %s does not match the provided value %s", diff --git a/tests/rest_api/tests/base_test.py b/tests/rest_api/tests/base_test.py index 2225f6e..9fca8e0 100644 --- a/tests/rest_api/tests/base_test.py +++ b/tests/rest_api/tests/base_test.py @@ -25,8 +25,8 @@ class BaseClass: ("4f", "PDFA_4_F", "PDF/A-4F validation profile", 108, ("6.2.4.2", 3)), ("ua1", "PDFUA_1", "PDF/UA-1 validation profile", 104, ("7.18.8", 1)), ("ua2", "PDFUA_2", "PDF/UA-2 + Tagged PDF validation profile", 1745, ("5", 5)), - ("wt1a", "WTPDF_1_0_ACCESSIBILITY", "WTPDF 1.0 Accessibility validation profile", 87, ("8.4.3", 3)), - ("wt1r", "WTPDF_1_0_REUSE", "WTPDF 1.0 Reuse validation profile", 74, ("8.4.5.4", 3)), + ("wt1a", "WTPDF_1_0_ACCESSIBILITY", "WTPDF 1.0 Accessibility validation profile", 1747, ("8.4.3", 3)), + ("wt1r", "WTPDF_1_0_REUSE", "WTPDF 1.0 Reuse validation profile", 1734, ("8.4.5.4", 3)), ) FLAVOURS_LIST = sorted(