Ticket #5083: validator-patch.patch
| File validator-patch.patch, 2.8 KB (added by , 16 years ago) |
|---|
-
src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java
140 140 protected static int PAINT = 1207; 141 141 protected static int LONG_VALUE = 1208; 142 142 protected static int LONG_KEY = 1209; 143 protected static int LOW_CHAR_VALUE = 1210; 144 protected static int LOW_CHAR_KEY = 1211; 143 145 /** 1250 and up is used by tagcheck */ 144 146 145 147 /** List of sources for spellcheck data */ … … 390 392 } 391 393 392 394 /** 395 * Checks given string (key or value) if it contains characters with code below 0x20 (either newline or some other special characters) 396 * @param s string to check 397 */ 398 private boolean containsLow(String s) { 399 if (s==null) return false; 400 for(int i=0;i<s.length();i++) { 401 if (s.charAt(i)<0x20) return true; 402 } 403 return false; 404 } 405 406 /** 393 407 * Checks the primitive properties 394 408 * @param p The primitive to check 395 409 */ … … 473 487 String s = marktr("Key ''{0}'' invalid."); 474 488 String key = prop.getKey(); 475 489 String value = prop.getValue(); 490 if( checkValues && (containsLow(value)) && !withErrors.contains(p, "ICV")) 491 { 492 errors.add( new TestError(this, Severity.WARNING, tr("Tag value contains character with code less than 0x20"), 493 tr(s, key), MessageFormat.format(s, key), LOW_CHAR_VALUE, p) ); 494 withErrors.add(p, "ICV"); 495 } 496 if( checkKeys && (containsLow(key)) && !withErrors.contains(p, "ICK")) 497 { 498 errors.add( new TestError(this, Severity.WARNING, tr("Tag key contains character with code less than 0x20"), 499 tr(s, key), MessageFormat.format(s, key), LOW_CHAR_KEY, p) ); 500 withErrors.add(p, "ICK"); 501 } 476 502 if( checkValues && (value!=null && value.length() > 255) && !withErrors.contains(p, "LV")) 477 503 { 478 504 errors.add( new TestError(this, Severity.ERROR, tr("Tag value longer than allowed"), 479 505 tr(s, key), MessageFormat.format(s, key), LONG_VALUE, p) ); 480 506 withErrors.add(p, "LV"); 481 507 } 482 if( checkKeys && ( value!=null && key.length() > 255) && !withErrors.contains(p, "LK"))508 if( checkKeys && (key!=null && key.length() > 255) && !withErrors.contains(p, "LK")) 483 509 { 484 510 errors.add( new TestError(this, Severity.ERROR, tr("Tag key longer than allowed"), 485 511 tr(s, key), MessageFormat.format(s, key), LONG_KEY, p) );
