Index: trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- trunk/src/org/openstreetmap/josm/Main.java	(revision 5853)
+++ trunk/src/org/openstreetmap/josm/Main.java	(revision 5854)
@@ -200,5 +200,5 @@
         if (log_level < 1)
             return;
-        System.out.println(msg);
+        System.err.println(tr("WARNING: {0}", msg));
     }
     /**
@@ -209,5 +209,5 @@
         if (log_level < 2)
             return;
-        System.out.println(msg);
+        System.err.println(tr("INFO: {0}", msg));
     }
     /**
@@ -218,5 +218,5 @@
         if (log_level < 3)
             return;
-        System.out.println(msg);
+        System.err.println(tr("DEBUG: {0}", msg));
     }
     /**
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 5853)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 5854)
@@ -1067,5 +1067,5 @@
 
                                 if (conn.getResponseCode() != 200) {
-                                    Main.info("INFO: {0} does not exist", u);
+                                    Main.info("{0} does not exist", u);
                                     conn.disconnect();
                                 } else {
@@ -1084,8 +1084,8 @@
                                      */
                                     if (Math.abs(conn.getContentLength() - osize) > 200) {
-                                        Main.info("INFO: {0} is a mediawiki redirect", u);
+                                        Main.info("{0} is a mediawiki redirect", u);
                                         conn.disconnect();
                                     } else {
-                                        Main.info("INFO: browsing to {0}", u);
+                                        Main.info("browsing to {0}", u);
                                         conn.disconnect();
 
Index: trunk/src/org/openstreetmap/josm/io/GpxReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/GpxReader.java	(revision 5853)
+++ trunk/src/org/openstreetmap/josm/io/GpxReader.java	(revision 5854)
@@ -423,12 +423,19 @@
      * Parse the input stream and store the result in trackData and markerData
      *
+     * @param source the source input stream
+     * @throws IOException if an IO error occurs, e.g. the input stream is closed.
      */
     public GpxReader(InputStream source) throws IOException {
-        this.inputSource = new InputSource(UTFInputStreamReader.create(source, "UTF-8"));
+        InputStream filtered = new InvalidXmlCharacterFilter(source);
+        this.inputSource = new InputSource(UTFInputStreamReader.create(filtered, "UTF-8"));
     }
 
     /**
+     * Parse the GPX data.
      *
-     * @return True if file was properly parsed, false if there was error during parsing but some data were parsed anyway
+     * @param tryToFinish true, if the reader should return at least part of the GPX
+     * data in case of an error.
+     * @return true if file was properly parsed, false if there was error during
+     * parsing but some data were parsed anyway
      * @throws SAXException
      * @throws IOException
Index: trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java	(revision 5854)
+++ trunk/src/org/openstreetmap/josm/io/InvalidXmlCharacterFilter.java	(revision 5854)
@@ -0,0 +1,69 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.io;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.openstreetmap.josm.Main;
+
+/**
+ * FilterInputStream that gets rid of characters that are invalid in an XML 1.0
+ * document.
+ *
+ * Although these characters are forbidden, in the real wold they still appear
+ * in XML files. Java's SAX parser throws an exception, so we have to filter
+ * at a lower level.
+ *
+ * Only handles control characters (&lt;0x20). Invalid characters are replaced
+ * by space (0x20).
+ */
+public class InvalidXmlCharacterFilter extends FilterInputStream {
+
+    public static boolean firstWarning = true;
+
+    public static final boolean[] INVALID_CHARS;
+    
+    static {
+        INVALID_CHARS = new boolean[0x20];
+        for (int i = 0; i < INVALID_CHARS.length; ++i) {
+            INVALID_CHARS[i] = true;
+        }
+        INVALID_CHARS[0x9] = false; // tab
+        INVALID_CHARS[0xA] = false; // LF
+        INVALID_CHARS[0xD] = false; // CR
+    }
+
+    public InvalidXmlCharacterFilter(InputStream in) {
+        super(in);
+    }
+
+    @Override
+    public int read() throws IOException {
+        return filter((byte)read());
+    }
+
+    @Override
+    public int read(byte[] b, int off, int len) throws IOException {
+        int n = super.read(b, off, len);
+        if (n == -1) {
+            return -1;
+        }
+        for (int i = off; i < off + len; ++i) {
+            b[i] = filter(b[i]);
+        }
+        return n;
+    }
+
+    private byte filter(byte in) {
+        if (in < 0x20 && in >= 0 && INVALID_CHARS[in]) {
+            if (firstWarning) {
+                Main.warn("Invalid xml character encountered.");
+                firstWarning = false;
+            }
+            return 0x20;
+        }
+        return in;
+    }
+
+}
Index: trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java	(revision 5853)
+++ trunk/src/org/openstreetmap/josm/io/UTFInputStreamReader.java	(revision 5854)
@@ -2,7 +2,7 @@
 package org.openstreetmap.josm.io;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.IOException;
 import java.io.PushbackInputStream;
 import java.io.UnsupportedEncodingException;
