diff --git a/jpos/src/main/java/org/jpos/core/Environment.java b/jpos/src/main/java/org/jpos/core/Environment.java index 01f4471132..4b61de7017 100644 --- a/jpos/src/main/java/org/jpos/core/Environment.java +++ b/jpos/src/main/java/org/jpos/core/Environment.java @@ -37,8 +37,8 @@ public class Environment implements Loggeable { private static final String SYSTEM_PREFIX = "sys"; private static final String ENVIRONMENT_PREFIX = "env"; - private static Pattern valuePattern = Pattern.compile("^(.*)(\\$)([\\w]*)\\{([-!\\w.]+)(:(.*?))?\\}(.*)$"); - // make groups easier to read :-) 11112222233333333 4444444444455666665 7777 + private static Pattern valuePattern = Pattern.compile("^((?:.|\n|\r)*)(\\$)([\\w]*)\\{([-!\\w.]+)(:(.*?))?\\}((?:.|\n|\r)*)$"); + // make groups easier to read :-) 111111111111112222233333333 4444444444455666665 77777777777777 private static Pattern verbPattern = Pattern.compile("^\\$verb\\{([\\w\\W]+)\\}$"); private static Environment INSTANCE; diff --git a/jpos/src/test/java/org/jpos/core/EnvironmentTest.java b/jpos/src/test/java/org/jpos/core/EnvironmentTest.java index 13f381bfc0..e200058fd7 100644 --- a/jpos/src/test/java/org/jpos/core/EnvironmentTest.java +++ b/jpos/src/test/java/org/jpos/core/EnvironmentTest.java @@ -97,6 +97,27 @@ public void multiExpr() { assertEquals("the numbers UNO and DOS and NaN", Environment.get("the numbers ${test.one} and ${test.two} and ${test.three:NaN}")); } + + @Test + public void multiLineExpression() { + assertEquals("The next sentence is true\nThe previous sentence is false\n", + Environment.getEnvironment().getProperty("The next sentence is ${undefined-property:true}\n" + + "The previous sentence is ${undefined-property:false}\n")); + } + + @Test + public void multiLineExpressionWithCR() { + assertEquals("The next sentence is true\rThe previous sentence is false\r", + Environment.getEnvironment().getProperty("The next sentence is ${undefined-property:true}\r" + + "The previous sentence is ${undefined-property:false}\r")); + } + + @Test + public void multiLineExpressionWithCRLF() { + assertEquals("The next sentence is true\r\nThe previous sentence is false\r\n", + Environment.getEnvironment().getProperty("The next sentence is ${undefined-property:true}\r\n" + + "The previous sentence is ${undefined-property:false}\r\n")); + } @Test public void testNegateExprFromEnvironment() {