From f63154b374ebc31be012da533d078c1193b24b83 Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Mon, 24 May 2021 15:19:49 -0700 Subject: [PATCH] Fix #352 node attribute expansion not working for ssh-xyz attributes * support `_-:` chars in output format key names --- .../src/main/java/org/rundeck/client/util/Format.java | 2 +- .../test/groovy/org/rundeck/client/util/FormatSpec.groovy | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rd-api-client/src/main/java/org/rundeck/client/util/Format.java b/rd-api-client/src/main/java/org/rundeck/client/util/Format.java index af066fa8..06e02abd 100644 --- a/rd-api-client/src/main/java/org/rundeck/client/util/Format.java +++ b/rd-api-client/src/main/java/org/rundeck/client/util/Format.java @@ -35,7 +35,7 @@ public static String format(String format, DataOutput data, final String start, } public static String format(String format, Map data, final String start, final String end) { - Pattern pat = Pattern.compile(Pattern.quote(start) + "([\\w.]+)" + Pattern.quote(end)); + Pattern pat = Pattern.compile(Pattern.quote(start) + "([\\w.:_-]+)" + Pattern.quote(end)); Matcher matcher = pat.matcher(format); StringBuffer sb = new StringBuffer(); while (matcher.find()) { diff --git a/rd-cli-tool/src/test/groovy/org/rundeck/client/util/FormatSpec.groovy b/rd-cli-tool/src/test/groovy/org/rundeck/client/util/FormatSpec.groovy index 3e90992a..82ddfc9c 100644 --- a/rd-cli-tool/src/test/groovy/org/rundeck/client/util/FormatSpec.groovy +++ b/rd-cli-tool/src/test/groovy/org/rundeck/client/util/FormatSpec.groovy @@ -37,6 +37,9 @@ class FormatSpec extends Specification { '%' | '' | 'a %b %c' | [b: 'x'] | 'a x ' '%' | '' | 'a %b %c' | [b: '$x'] | 'a $x ' '%' | '' | 'a %b %c' | [b: '\\x'] | 'a \\x ' + '%' | '' | 'a %b-x q' | ['b-x': 'z'] | 'a z q' + '%' | '' | 'a %b_x r' | ['b_x': 'z'] | 'a z r' + '%' | '' | 'a %b:x r' | ['b:x': 'z'] | 'a z r' } @@ -52,6 +55,10 @@ class FormatSpec extends Specification { '${' | '}' | '${b.c} b c' | [a: 'x', b: [c: 'd']] | 'd b c' '${' | '}' | '${b.DNE} b c' | [a: 'x', b: [c: 'd']] | ' b c' '${' | '}' | '${a.b} b c' | [a: 'x', b: [c: 'd']] | ' b c' + '%' | '' | '%a.b b c' | [a: 'x', b: [c: 'd']] | ' b c' + '%' | '' | '%b.c-d q r' | [a: 'x', b: ['c-d': 'e']] | 'e q r' + '%' | '' | '%b.c_d q r' | [a: 'x', b: ['c_d': 'e']] | 'e q r' + '%' | '' | '%b.c:d q r' | [a: 'x', b: ['c:d': 'e']] | 'e q r' } }