Skip to content

Commit

Permalink
Merge pull request #5 from slide/7f437947b485d56895cff3a6e48450d6192e…
Browse files Browse the repository at this point in the history
…26bb

Fix JENKINS-12685
Thanks !
  • Loading branch information
olamy committed Feb 15, 2012
2 parents da2858d + 7f43794 commit 38919bf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Expand Up @@ -61,7 +61,7 @@ class Tokenizer {

private static final String delimitedTokenRegex = "\\{" + spaceRegex + "(" + tokenNameRegex + ")" + argsRegex + spaceRegex + "\\}";

private static final String tokenRegex = "\\$((" + tokenNameRegex + ")|(" + delimitedTokenRegex + "))";
private static final String tokenRegex = "(?<!\\\\)\\$((" + tokenNameRegex + ")|(" + delimitedTokenRegex + "))";

private static final Pattern argPattern = Pattern.compile(argRegex);

Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/jenkinsci/plugins/tokenmacro/TokenMacroTest.java
Expand Up @@ -37,6 +37,19 @@ public void testNested() throws Exception {

assertEquals("{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"${TEST_NESTED}"));
}

public void testEscaped() throws Exception {
FreeStyleProject p = createFreeStyleProject("foo");
FreeStyleBuild b = p.scheduleBuild2(0).get();

listener = new StreamTaskListener(System.out);
assertEquals("\\${TEST_NESTED}",TokenMacro.expand(b,listener,"\\${TEST_NESTED}"));
assertEquals("\\$TEST_NESTED",TokenMacro.expand(b,listener,"\\$TEST_NESTED"));
assertEquals("\\$TEST_NESTED{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"\\$TEST_NESTED$TEST_NESTED"));
assertEquals("\\${TEST_NESTED}{abc=[def, ghi], jkl=[true]}",TokenMacro.expand(b,listener,"\\${TEST_NESTED}$TEST_NESTED"));
assertEquals("{abc=[def, ghi], jkl=[true]}\\$TEST_NESTED",TokenMacro.expand(b,listener,"$TEST_NESTED\\$TEST_NESTED"));
assertEquals("{abc=[def, ghi], jkl=[true]}\\${TEST_NESTED}",TokenMacro.expand(b,listener,"$TEST_NESTED\\${TEST_NESTED}"));
}

@TestExtension
public static class TestMacro extends TokenMacro {
Expand Down

0 comments on commit 38919bf

Please sign in to comment.