Skip to content

Commit

Permalink
fixed parsing of pipe symbol in selectable options
Browse files Browse the repository at this point in the history
  • Loading branch information
pdbro2k committed Nov 22, 2023
1 parent a5aeeb3 commit 513e41c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ public class SelectableOptionFactory {
* (i.e. <code>"real|rendered"</code> vs. <code>"rendered|real"</code>))
*/
public static SelectableOption<String> createOption(String serializedOption, CharSequence delimiter, boolean realValueFirst, boolean reduceWhitespace) {
String[] values = serializedOption.split(Pattern.quote(""+delimiter));
String[] values = serializedOption.split(Pattern.quote("\""+delimiter+"\""));
switch (values.length) {
case 1:
if (reduceWhitespace)
serializedOption = StringUtils.reduceWhitespace(serializedOption);
return new SelectableOption<String>(serializedOption);
case 2:
// get values
String realValue = realValueFirst ? values[0] : values[1];
String renderedValue = realValueFirst ? values[1] : values[0];
String realValue = StringUtils.removeEnclosingQuotes(realValueFirst ? values[0] : values[1]);
String renderedValue = StringUtils.removeEnclosingQuotes(realValueFirst ? values[1] : values[0]);

// reduce whitespace
if (reduceWhitespace) {
Expand All @@ -43,7 +43,7 @@ public static SelectableOption<String> createOption(String serializedOption, Cha
}

// return option
return new SelectableOption<String>(realValue, renderedValue);
return new SelectableOption<String>(StringUtils.removeEscapedQuotes(realValue), StringUtils.removeEscapedQuotes(renderedValue));
default:
throw new IllegalArgumentException("Could not parse "+serializedOption);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public static Map<String, BasicInputField<String>> createDialogModel(List<String
if (optionGroup != null && !optionGroup.isEmpty()) {
String[] encodedOptions = matcher.group(2).split("(?<=\" ?),");
for (String encodedOption: encodedOptions) {
encodedOption = StringUtils.removeEnclosingQuotes(encodedOption);
encodedOption = StringUtils.removeEscapedQuotes(encodedOption);
options.add(SelectableOptionFactory.createOption(encodedOption, "|", true, true));
}
}
Expand Down

0 comments on commit 513e41c

Please sign in to comment.