Index: trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/actions/upload/FixDataHook.java	(revision 6699)
@@ -19,4 +19,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.osm.Tag;
 
 /**
@@ -76,6 +77,6 @@
             Map<String, String> newKeys = new HashMap<String, String>(keys);
             for (Entry<String, String> e : keys.entrySet()) {
-                String v = e.getValue().trim();
-                String k = e.getKey().trim();
+                String v = Tag.removeWhiteSpaces(e.getValue());
+                String k = Tag.removeWhiteSpaces(e.getKey());
                 if(!e.getKey().equals(k)) {
                     boolean drop = k.isEmpty() || v.isEmpty();
Index: trunk/src/org/openstreetmap/josm/data/osm/Tag.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/Tag.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/data/osm/Tag.java	(revision 6699)
@@ -3,4 +3,5 @@
 
 import org.openstreetmap.josm.tools.CheckParameterUtil;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -17,5 +18,5 @@
      * Create an empty tag whose key and value are empty.
      */
-    public Tag(){
+    public Tag() {
         this("", "");
     }
@@ -119,3 +120,16 @@
         return key + "=" + value;
     }
+
+    /**
+     * Removes leading, trailing, and multiple inner whitespaces from the given string, to be used as a key or value.
+     * @param s The string
+     * @return The string without leading, trailing or multiple inner whitespaces
+     * @since 6699
+     */
+    public static String removeWhiteSpaces(String s) {
+        if (s == null || s.isEmpty()) {
+            return s;
+        }
+        return Utils.strip(s).replaceAll("\\s+", " ");
+    }
 }
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java	(revision 6699)
@@ -142,5 +142,5 @@
                         CheckParameterUtil.ensureThat(val.contains("=>"), "Separate old from new key by '=>'!");
                         final String[] x = val.split("=>", 2);
-                        check.keyChange.put(x[0].trim(), x[1].trim());
+                        check.keyChange.put(Tag.removeWhiteSpaces(x[0]), Tag.removeWhiteSpaces(x[1]));
                     } else if ("suggestAlternative".equals(ai.key) && val != null) {
                         check.alternatives.add(val);
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java	(revision 6699)
@@ -36,4 +36,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
 import org.openstreetmap.josm.data.osm.OsmUtils;
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.data.validation.Severity;
 import org.openstreetmap.josm.data.validation.Test;
@@ -563,7 +564,7 @@
                     commands.add(new ChangePropertyCommand(p, key, null));
                 } else if (value.startsWith(" ") || value.endsWith(" ")) {
-                    commands.add(new ChangePropertyCommand(p, key, value.trim()));
+                    commands.add(new ChangePropertyCommand(p, key, Tag.removeWhiteSpaces(value)));
                 } else if (key.startsWith(" ") || key.endsWith(" ")) {
-                    commands.add(new ChangePropertyKeyCommand(p, key, key.trim()));
+                    commands.add(new ChangePropertyKeyCommand(p, key, Tag.removeWhiteSpaces(key)));
                 } else {
                     String evalue = entities.unescape(value);
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java	(revision 6699)
@@ -32,4 +32,5 @@
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionList;
@@ -189,5 +190,5 @@
         if (primitives == null || primitives.isEmpty())
             return null;
-        return new ChangePropertyCommand(primitives, tfKey.getText(), tfValue.getText());
+        return new ChangePropertyCommand(primitives, Tag.removeWhiteSpaces(tfKey.getText()), Tag.removeWhiteSpaces(tfValue.getText()));
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/TagEditHelper.java	(revision 6699)
@@ -331,5 +331,5 @@
          */
         private void performTagEdit() {
-            String value = values.getEditor().getItem().toString().trim();
+            String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString());
             // is not Java 1.5
             //value = java.text.Normalizer.normalize(value, java.text.Normalizer.Form.NFC);
@@ -337,5 +337,5 @@
                 value = null; // delete the key
             }
-            String newkey = keys.getEditor().getItem().toString().trim();
+            String newkey = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString());
             //newkey = java.text.Normalizer.normalize(newkey, java.text.Normalizer.Form.NFC);
             if (newkey.isEmpty()) {
@@ -732,6 +732,6 @@
          */
         public void performTagAdding() {
-            String key = keys.getEditor().getItem().toString().trim();
-            String value = values.getEditor().getItem().toString().trim();
+            String key = Tag.removeWhiteSpaces(keys.getEditor().getItem().toString());
+            String value = Tag.removeWhiteSpaces(values.getEditor().getItem().toString());
             if (key.isEmpty() || value.isEmpty()) return;
             lastAddKey = key;
@@ -743,9 +743,7 @@
         }
         
-        
         public void undoAllTagsAdding() {
             Main.main.undoRedo.undo(commandCount);
         }
-
 
         private void disableTagIfNeeded(final Tag t, final JosmAction action) {
Index: trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java	(revision 6695)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java	(revision 6699)
@@ -714,5 +714,5 @@
             }
             
-            v = v.trim();
+            v = Tag.removeWhiteSpaces(v);
 
             if (!"false".equals(use_last_as_default) || auto_increment != null) {
@@ -1076,5 +1076,5 @@
                 value = "";
             }
-            value = value.trim();
+            value = Tag.removeWhiteSpaces(value);
 
             // no change if same as before
