Skip to content

Commit

Permalink
prevent loop in Envirnoment.get
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Jan 1, 2022
1 parent 67e4ee4 commit c27ebd1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions jpos/src/main/java/org/jpos/core/Environment.java
Expand Up @@ -127,6 +127,7 @@ public String getProperty (String s) {
return s; // return the whole thing

while (m != null && m.matches()) {
String previousR = r;
String gPrefix = m.group(3);
String gValue = m.group(4);
gPrefix = gPrefix != null ? gPrefix : "";
Expand Down Expand Up @@ -173,6 +174,9 @@ public String getProperty (String s) {
}
else
m = null;

if (Objects.equals(r, previousR))
break;
}
}
return r;
Expand Down
6 changes: 6 additions & 0 deletions jpos/src/test/java/org/jpos/core/EnvironmentTest.java
Expand Up @@ -83,4 +83,10 @@ public void testObfuscated() {
System.setProperty("obf.value", "obf::D4sCOgAAAASneiqWUPCruOtNmAU78cg6uBAv3N0/8DSNK6ptaozLAg==");
assertEquals("OBFUSCATED ABCD", Environment.get("OBFUSCATED ${obf.value}"));
}

@Test
public void testLoop() {
System.setProperty("loop", "${loop}");
assertEquals("${loop}", Environment.get("${loop}"));
}
}

0 comments on commit c27ebd1

Please sign in to comment.