Skip to content

Commit

Permalink
Fix #352 node attribute expansion not working for ssh-xyz attributes
Browse files Browse the repository at this point in the history
* support `_-:` chars in output format key names
  • Loading branch information
gschueler committed May 26, 2021
1 parent 5a7555a commit f63154b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

}

Expand All @@ -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'

}
}

0 comments on commit f63154b

Please sign in to comment.