From 6b4aa287102a5de98ad03fd8965515c416d93044 Mon Sep 17 00:00:00 2001 From: ralph isenmann Date: Tue, 1 Dec 2020 14:21:17 +0100 Subject: [client] fix eol separator A given dockerfile with windows eol style ("\r\n") will now be converted to unix eol ("\n") --- .../java/org/openslx/dozmod/model/ContainerDefinition.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'dozentenmodul/src/main/java') diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java index 46dba2e0..92ec6607 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/model/ContainerDefinition.java @@ -145,16 +145,22 @@ public class ContainerDefinition { } private String readContainerRecipe(File file) { - byte[] rawFile = null; + String recipe = null; try { + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); - rawFile = new byte[(int) file.length()]; + byte[] rawFile = new byte[(int) file.length()]; bis.read(rawFile); + String rawRecipe = new String(rawFile, StandardCharsets.UTF_8); + + // replace windows by unix EOL + recipe = rawRecipe.replaceAll("\\r\\n", "\n"); + } catch (IOException e) { LOGGER.error("Could not read Container Recipe", e); } - return new String(rawFile, StandardCharsets.UTF_8); + return recipe; } /** -- cgit v1.2.3-55-g7522