Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.ashald.envfile.AbstractEnvVarsProvider;
import net.ashald.envfile.EnvFileErrorException;
import org.apache.commons.text.StringEscapeUtils;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down Expand Up @@ -43,7 +44,7 @@ protected Map<String, String> getEnvVars(@NotNull Map<String, String> runConfigE
}

private static String trim(String value) {
String trimmed = value.trim();
String trimmed = StringEscapeUtils.unescapeJava(value.trim()) ;

if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) || (trimmed.startsWith("'") && trimmed.endsWith("'")))
return trimmed.substring(1, trimmed.length() - 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,11 @@ public void testOrder() throws EnvFileErrorException, IOException {
Assert.assertEquals("A(B(C))", result.get("A"));
}

@Test
public void testMultiLine() throws EnvFileErrorException {
Map<String, String> result = parser.getEnvVars(Collections.emptyMap(), getFile("multiline.env"));
Assert.assertEquals(1, result.size());
Assert.assertEquals("this\nis\nmultiline", result.get("A"));
}

}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
TEST_VAR=value\1
TEST_VAR=value\\1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ key1=foo#bar
key2=foo #bar
key3='foo #bar'
key4="foo #bar"
key5=foo \#bar
key5=foo \\#bar
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FOO=\usr
FOO=\\usr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A="this\nis\nmultiline"