Ticket #8902: entities.diff
| File entities.diff, 3.3 KB (added by , 12 years ago) |
|---|
-
src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
144 144 /** List of sources for spellcheck data */ 145 145 protected JList sourcesList; 146 146 147 protected static final Entities entities = new Entities();148 149 147 /** 150 148 * Constructor 151 149 */ … … 411 409 tr(s, key), MessageFormat.format(s, key), INVALID_SPACE, p) ); 412 410 withErrors.put(p, "SPACE"); 413 411 } 414 if (checkValues && value != null && !value.equals( entities.unescape(value)) && !withErrors.contains(p, "HTML")) {412 if (checkValues && value != null && !value.equals(Entities.unescape(value)) && !withErrors.contains(p, "HTML")) { 415 413 errors.add( new TestError(this, Severity.OTHER, tr("Property values contain HTML entity"), 416 414 tr(s, key), MessageFormat.format(s, key), INVALID_HTML, p) ); 417 415 withErrors.put(p, "HTML"); … … 721 719 } else if (key.startsWith(" ") || key.endsWith(" ")) { 722 720 commands.add(new ChangePropertyKeyCommand(Collections.singleton(p), key, key.trim())); 723 721 } else { 724 String evalue = entities.unescape(value);722 String evalue = Entities.unescape(value); 725 723 if (!evalue.equals(value)) { 726 724 commands.add(new ChangePropertyCommand(Collections.singleton(p), key, evalue)); 727 725 } else { -
src/org/openstreetmap/josm/data/validation/util/Entities.java
334 334 {"euro", "8364"}, // -- euro sign, U+20AC NEW --> 335 335 }; 336 336 337 private static Map<String, String> mapNameToValue = null;337 private static final Map<String, Integer> MAP_NAME_TO_VALUE = new HashMap<String, Integer>(); 338 338 339 public String unescape(String str) { 339 static { 340 for (String[] pair : ARRAY) { 341 MAP_NAME_TO_VALUE.put(pair[0], Integer.parseInt(pair[1])); 342 } 343 } 344 345 public static String unescape(String str) { 340 346 int firstAmp = str.indexOf('&'); 341 347 if (firstAmp < 0) 342 348 return str; … … 384 390 } 385 391 } 386 392 } else { // escaped value content is an entity name 387 if(mapNameToValue == null) 388 { 389 mapNameToValue = new HashMap<String, String>(); 390 for (String[] pair : ARRAY) 391 mapNameToValue.put(pair[0], pair[1]); 392 } 393 String value = mapNameToValue.get(entityContent); 394 entityValue = (value == null ? -1 : Integer.parseInt(value)); 393 final Integer value = MAP_NAME_TO_VALUE.get(entityContent); 394 if (value != null) entityValue = value; 395 395 } 396 396 } 397 397
