| 283 | | Set<String> tagSet = new LinkedHashSet<>(); // preserve order, see #15704 |
| 284 | | for (String tag1 : args.get("addtags").split("\\|")) { |
| 285 | | if (!tag1.trim().isEmpty() && tag1.contains("=")) { |
| 286 | | tagSet.add(tag1.trim()); |
| 287 | | } |
| 288 | | } |
| 289 | | if (!tagSet.isEmpty()) { |
| 290 | | String[][] keyValue = new String[tagSet.size()][2]; |
| 291 | | int i = 0; |
| 292 | | for (String tag2 : tagSet) { |
| 293 | | // support a = b===c as "a"="b===c" |
| 294 | | String[] pair = tag2.split("\\s*=\\s*", 2); |
| 295 | | keyValue[i][0] = pair[0]; |
| 296 | | keyValue[i][1] = pair.length < 2 ? "" : pair[1]; |
| 297 | | i++; |
| 298 | | } |
| 299 | | addTags(keyValue, sender, primitives); |
| 300 | | } |
| | 283 | addTags(parseUrlTagsToKeyValues(args.get("addtags")), sender, primitives); |
| | 289 | * Convert a argument from a url to a series of tags |
| | 290 | * @param urlSection A url section that looks like {@code tag1=value1|tag2=value2} |
| | 291 | * @return An 2d array in the format of {@code [key][value]} |
| | 292 | * @since xxx |
| | 293 | */ |
| | 294 | public static String[][] parseUrlTagsToKeyValues(String urlSection) { |
| | 295 | Set<String> tagSet = new LinkedHashSet<>();// preserve order, see #15704 |
| | 296 | String[][] keyValue = new String[][] {}; |
| | 297 | for (String tag : urlSection.split("\\|")) { |
| | 298 | if (!tag.trim().isEmpty() && tag.contains("=")) { |
| | 299 | tagSet.add(tag.trim()); |
| | 300 | } |
| | 301 | } |
| | 302 | if (!tagSet.isEmpty()) { |
| | 303 | keyValue = new String[tagSet.size()][2]; |
| | 304 | int i = 0; |
| | 305 | for (String tag : tagSet) { |
| | 306 | // support a = b===c as "a"="b===c" |
| | 307 | String[] pair = tag.split("\\s*=\\s*", 2); |
| | 308 | keyValue[i][0] = pair[0]; |
| | 309 | keyValue[i][1] = pair.length < 2 ? "" : pair[1]; |
| | 310 | i++; |
| | 311 | } |
| | 312 | } |
| | 313 | return keyValue; |
| | 314 | } |
| | 315 | |
| | 316 | /** |