Index: trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java	(revision 7782)
+++ trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java	(revision 7783)
@@ -80,6 +80,6 @@
                 String v = Tag.removeWhiteSpaces(e.getValue());
                 String k = Tag.removeWhiteSpaces(e.getKey());
+                boolean drop = k.isEmpty() || v.isEmpty();
                 if(!e.getKey().equals(k)) {
-                    boolean drop = k.isEmpty() || v.isEmpty();
                     if(drop || !keys.containsKey(k)) {
                         newKeys.remove(e.getKey());
@@ -92,4 +92,6 @@
                     else
                         newKeys.put(k, v);
+                } else if (drop) {
+                    newKeys.remove(e.getKey());
                 }
             }
Index: trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 7782)
+++ trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java	(revision 7783)
@@ -18,4 +18,6 @@
 import java.util.concurrent.atomic.AtomicLong;
 
+import org.openstreetmap.josm.tools.Utils;
+
 /**
 * Abstract class to represent common features of the datatypes primitives.
@@ -509,5 +511,5 @@
      * removes the key and behaves like {@link #remove(String)}.
      *
-     * @param key  The key, for which the value is to be set. Can be null, does nothing in this case.
+     * @param key  The key, for which the value is to be set. Can be null or empty, does nothing in this case.
      * @param value The value for the key. If null, removes the respective key/value pair.
      *
@@ -517,5 +519,5 @@
     public void put(String key, String value) {
         Map<String, String> originalKeys = getKeys();
-        if (key == null)
+        if (key == null || Utils.strip(key).isEmpty())
             return;
         else if (value == null) {
Index: trunk/src/org/openstreetmap/josm/tools/TextTagParser.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/TextTagParser.java	(revision 7782)
+++ trunk/src/org/openstreetmap/josm/tools/TextTagParser.java	(revision 7783)
@@ -204,5 +204,5 @@
         // Format
         // tag1\tval1\ntag2\tval2\n
-        tags = readTagsByRegexp(buf, "[\\r\\n]+", "(.*?)\\t(.*?)", false);
+        tags = readTagsByRegexp(buf, "[\\r\\n]+", "([a-zA-Z0-9:_]+)\\t(.*?)", false);
                 // try "tag\tvalue\n" format
         if (tags!=null) return tags;
@@ -213,5 +213,5 @@
         // a = "b=c" is OK
         // a = b=c  - this method of parsing fails intentionally
-        tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "(.*?)=(.*?)", true);
+        tags = readTagsByRegexp(buf, "[\\n\\t\\r]+", "([a-zA-Z0-9:_]+)=(.*?)", true);
                 // try format  t1=v1\n t2=v2\n ...
         if (tags!=null) return tags;
