|
|
|
@ -619,7 +619,27 @@ public class Helper {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String sanitizeKeyword(String keyword) {
|
|
|
|
|
// ()}%*"\]
|
|
|
|
|
return keyword.replaceAll("[^A-Za-z0-9$_.]", "");
|
|
|
|
|
// https://tools.ietf.org/html/rfc3501
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
for (int i = 0; i < keyword.length(); i++) {
|
|
|
|
|
// flag-keyword = atom
|
|
|
|
|
// atom = 1*ATOM-CHAR
|
|
|
|
|
// ATOM-CHAR = <any CHAR except atom-specials>
|
|
|
|
|
Character kar = keyword.charAt(i);
|
|
|
|
|
// atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / quoted-specials / resp-specials
|
|
|
|
|
if (kar == '(' || kar == ')' || kar == '{' || kar == ' ' || Character.isISOControl(kar))
|
|
|
|
|
continue;
|
|
|
|
|
// list-wildcards = "%" / "*"
|
|
|
|
|
if (kar == '%' || kar == '*')
|
|
|
|
|
continue;
|
|
|
|
|
// quoted-specials = DQUOTE / "\"
|
|
|
|
|
if (kar == '"' || kar == '\\')
|
|
|
|
|
continue;
|
|
|
|
|
// resp-specials = "]"
|
|
|
|
|
if (kar == ']')
|
|
|
|
|
continue;
|
|
|
|
|
sb.append(kar);
|
|
|
|
|
}
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|