Changeset 7783 in josm


Ignore:
Timestamp:
2014-12-10T22:07:39+01:00 (6 years ago)
Author:
Don-vip
Message:

fix #10816 - add various safeguards to make sure to not upload empty keys

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java

    r7005 r7783  
    8080                String v = Tag.removeWhiteSpaces(e.getValue());
    8181                String k = Tag.removeWhiteSpaces(e.getKey());
     82                boolean drop = k.isEmpty() || v.isEmpty();
    8283                if(!e.getKey().equals(k)) {
    83                     boolean drop = k.isEmpty() || v.isEmpty();
    8484                    if(drop || !keys.containsKey(k)) {
    8585                        newKeys.remove(e.getKey());
     
    9292                    else
    9393                        newKeys.put(k, v);
     94                } else if (drop) {
     95                    newKeys.remove(e.getKey());
    9496                }
    9597            }
  • trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java

    r7509 r7783  
    1818import java.util.concurrent.atomic.AtomicLong;
    1919
     20import org.openstreetmap.josm.tools.Utils;
     21
    2022/**
    2123* Abstract class to represent common features of the datatypes primitives.
     
    509511     * removes the key and behaves like {@link #remove(String)}.
    510512     *
    511      * @param key  The key, for which the value is to be set. Can be null, does nothing in this case.
     513     * @param key  The key, for which the value is to be set. Can be null or empty, does nothing in this case.
    512514     * @param value The value for the key. If null, removes the respective key/value pair.
    513515     *
     
    517519    public void put(String key, String value) {
    518520        Map<String, String> originalKeys = getKeys();
    519         if (key == null)
     521        if (key == null || Utils.strip(key).isEmpty())
    520522            return;
    521523        else if (value == null) {
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r7005 r7783  
    204204        // Format
    205205        // tag1\tval1\ntag2\tval2\n
    206         tags = readTagsByRegexp(buf, "[\\r\\n]+", "(.*?)\\t(.*?)", false);
     206        tags = readTagsByRegexp(buf, "[\\r\\n]+", "([a-zA-Z0-9:_]+)\\t(.*?)", false);
    207207                // try "tag\tvalue\n" format
    208208        if (tags!=null) return tags;
     
    213213        // a = "b=c" is OK
    214214        // a = b=c  - this method of parsing fails intentionally
    215         tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "(.*?)=(.*?)", true);
     215        tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "([a-zA-Z0-9:_]+)=(.*?)", true);
    216216                // try format  t1=v1\n t2=v2\n ...
    217217        if (tags!=null) return tags;
Note: See TracChangeset for help on using the changeset viewer.