is gen_config invoked too often now? #2387

how about we do not trust anyone to properly handle EOL CRLF?
This commit is contained in:
rusefillc 2021-03-05 20:35:53 -05:00
parent 60c0fabad3
commit bc7ff44cb2
2 changed files with 7 additions and 8 deletions

Binary file not shown.

View File

@ -593,16 +593,15 @@ public class ConfigDefinition {
private static long getCrc32(String fileName) throws IOException {
File file = new File(fileName);
byte[] f1 = Files.readAllBytes(file.toPath());
CRC32 c = new CRC32();
c.update(f1, 0, f1.length);
return c.getValue();
byte[] fileContent = Files.readAllBytes(file.toPath());
for (int i = 0; i < fileContent.length; i++) {
byte aByte = fileContent[i];
if (aByte == '\r')
throw new IllegalStateException("CR \\r 0x0D byte not allowed in cacheable content " + fileName + " at index=" + i);
}
private static void deleteFile(String fileName) throws IOException {
File file = new File(fileName);
// todo: validate?
file.delete();
CRC32 c = new CRC32();
c.update(fileContent, 0, fileContent.length);
return c.getValue();
}
private static byte[] unzipFileContents(String zipFileName, String fileName) throws IOException {