Changeset 9744 in josm for trunk/src/org


Ignore:
Timestamp:
2016-02-06T20:20:54+01:00 (8 years ago)
Author:
Don-vip
Message:

fix #12499 - detect and fix multiple spaces in tag values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java

    r9404 r9744  
    127127    protected static final int MISSPELLED_VALUE  = 1212;
    128128    protected static final int MISSPELLED_KEY    = 1213;
     129    protected static final int MULTIPLE_SPACES   = 1214;
    129130    /** 1250 and up is used by tagcheck */
    130131
     
    429430                errors.add(new TestError(this, Severity.WARNING, tr("Property values start or end with white space"),
    430431                        tr(s, key), MessageFormat.format(s, key), INVALID_SPACE, p));
     432                withErrors.put(p, "SPACE");
     433            }
     434            if (checkValues && value != null && value.contains("  ") && !withErrors.contains(p, "SPACE")) {
     435                errors.add(new TestError(this, Severity.WARNING, tr("Property values contain multiple white spaces"),
     436                        tr(s, key), MessageFormat.format(s, key), MULTIPLE_SPACES, p));
    431437                withErrors.put(p, "SPACE");
    432438            }
     
    654660                    if (value == null || value.trim().isEmpty()) {
    655661                        commands.add(new ChangePropertyCommand(p, key, null));
    656                     } else if (value.startsWith(" ") || value.endsWith(" ")) {
     662                    } else if (value.startsWith(" ") || value.endsWith(" ") || value.contains("  ")) {
    657663                        commands.add(new ChangePropertyCommand(p, key, Tag.removeWhiteSpaces(value)));
    658                     } else if (key.startsWith(" ") || key.endsWith(" ")) {
     664                    } else if (key.startsWith(" ") || key.endsWith(" ") || key.contains("  ")) {
    659665                        commands.add(new ChangePropertyKeyCommand(p, key, Tag.removeWhiteSpaces(key)));
    660666                    } else {
     
    681687            int code = testError.getCode();
    682688            return code == INVALID_KEY || code == EMPTY_VALUES || code == INVALID_SPACE ||
    683                    code == INVALID_KEY_SPACE || code == INVALID_HTML || code == MISSPELLED_VALUE;
     689                   code == INVALID_KEY_SPACE || code == INVALID_HTML || code == MISSPELLED_VALUE ||
     690                   code == MULTIPLE_SPACES;
    684691        }
    685692
Note: See TracChangeset for help on using the changeset viewer.