Skip to content

Commit

Permalink
GUACAMOLE-1976: Add OPTIONAL token modifier.
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman committed Aug 9, 2024
1 parent deb858a commit a799d91
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,21 @@ private String filter(String input, boolean strict)
// strict mode is enabled
if (tokenValue == null) {

// Token marked as optional, so just skip it and update
// last match.
if (modifier != null && modifier.equals("OPTIONAL")) {
endOfLastMatch = tokenMatcher.end();
continue;
}

// Fail outright if strict mode is enabled
if (strict)
throw new GuacamoleTokenUndefinedException("Token "
+ "has no defined value.", tokenName);

// If strict mode is NOT enabled, simply interpret as
// a literal
String notToken = tokenMatcher.group(TOKEN_GROUP);
output.append(notToken);
output.append(tokenMatcher.group(TOKEN_GROUP));

}

Expand Down

0 comments on commit a799d91

Please sign in to comment.