Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
r15040 r15051 599 599 } 600 600 601 static String validateUploadTag(String uploadValue, String preferencePrefix, List<String> defMandatory, List<String> defForbidden) { 601 static String validateUploadTag(String uploadValue, String preferencePrefix, 602 List<String> defMandatory, List<String> defForbidden, List<String> defException) { 602 603 String uploadValueLc = lower(uploadValue); 603 604 // Check mandatory terms … … 608 609 } 609 610 // Check forbidden terms 611 List<String> exceptions = Config.getPref().getList(preferencePrefix+".exception-terms", defException); 610 612 List<String> forbiddenTerms = Config.getPref().getList(preferencePrefix+".forbidden-terms", defForbidden) 611 .stream().map(UploadAction::lower).filter(uploadValueLc::contains).collect(Collectors.toList()); 613 .stream().map(UploadAction::lower) 614 .filter(x -> uploadValueLc.contains(x) && !exceptions.stream().anyMatch(uploadValueLc::contains)) 615 .collect(Collectors.toList()); 612 616 if (!forbiddenTerms.isEmpty()) { 613 617 return tr("The following forbidden terms have been found: {0}", forbiddenTerms); … … 624 628 final String uploadComment = dialog.getUploadComment(); 625 629 final String uploadCommentRejection = validateUploadTag( 626 uploadComment, "upload.comment", def, def );630 uploadComment, "upload.comment", def, def, def); 627 631 if ((isUploadCommentTooShort(uploadComment) && warnUploadComment()) || 628 632 (uploadCommentRejection != null && warnRejectedUploadComment(uploadCommentRejection))) { … … 633 637 final String uploadSource = dialog.getUploadSource(); 634 638 final String uploadSourceRejection = validateUploadTag( 635 uploadSource, "upload.source", def, def );639 uploadSource, "upload.source", def, def, def); 636 640 if ((Utils.isStripEmpty(uploadSource) && warnUploadSource()) || 637 641 (uploadSourceRejection != null && warnRejectedUploadSource(uploadSourceRejection))) { -
trunk/test/unit/org/openstreetmap/josm/gui/io/UploadDialogTest.java
r15015 r15051 265 265 Config.getPref().putList(prefix + ".mandatory-terms", null); 266 266 Config.getPref().putList(prefix + ".forbidden-terms", null); 267 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def ));267 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def, def)); 268 268 269 269 Config.getPref().putList(prefix + ".mandatory-terms", Arrays.asList("foo")); 270 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def ));270 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def, def)); 271 271 assertEquals("The following required terms are missing: [foo]", 272 UploadAction.validateUploadTag("bar", prefix, def, def ));272 UploadAction.validateUploadTag("bar", prefix, def, def, def)); 273 273 274 274 Config.getPref().putList(prefix + ".forbidden-terms", Arrays.asList("bar")); 275 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def)); 276 assertEquals("The following forbidden terms have been found: [bar]", 277 UploadAction.validateUploadTag("foobar", prefix, def, def)); 278 assertEquals("The following forbidden terms have been found: [bar]", 279 UploadAction.validateUploadTag("FOOBAR", prefix, def, def)); 275 assertNull(UploadAction.validateUploadTag("foo", prefix, def, def, def)); 276 assertEquals("The following forbidden terms have been found: [bar]", 277 UploadAction.validateUploadTag("foobar", prefix, def, def, def)); 278 assertEquals("The following forbidden terms have been found: [bar]", 279 UploadAction.validateUploadTag("FOOBAR", prefix, def, def, def)); 280 281 Config.getPref().putList(prefix + ".exception-terms", Arrays.asList("barosm")); 282 assertEquals("The following forbidden terms have been found: [bar]", 283 UploadAction.validateUploadTag("foobar", prefix, def, def, def)); 284 assertEquals("The following forbidden terms have been found: [bar]", 285 UploadAction.validateUploadTag("FOOBAR", prefix, def, def, def)); 286 assertNull(UploadAction.validateUploadTag("foobarosm", prefix, def, def, def)); 287 assertNull(UploadAction.validateUploadTag("FOOBAROSM", prefix, def, def, def)); 280 288 } 281 289
Note:
See TracChangeset
for help on using the changeset viewer.