Index: /trunk/src/org/openstreetmap/josm/data/Version.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/data/Version.java	(revision 5868)
@@ -6,5 +6,4 @@
 import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStreamReader;
 import java.net.URL;
 import java.util.HashMap;
@@ -15,4 +14,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.tools.LanguageInfo;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -35,8 +35,7 @@
     static public String loadResourceFile(URL resource) {
         if (resource == null) return null;
-        BufferedReader in;
         String s = null;
         try {
-            in = new BufferedReader(new InputStreamReader(resource.openStream(), "UTF-8"));
+            BufferedReader in = Utils.openURLReader(resource);
             StringBuffer sb = new StringBuffer();
             try {
@@ -227,3 +226,12 @@
         return "JOSM/1.5 ("+ s+" "+LanguageInfo.getJOSMLocaleCode()+") " + Main.platform.getOSDescription();
     }
+
+    /**
+     * Returns the full User-Agent string
+     * @return The User-Agent
+     * @since 5866
+     */
+    public String getFullAgentString() {
+        return getAgentString() + " Java/"+System.getProperty("java.version");
+    }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/MainApplication.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/gui/MainApplication.java	(revision 5868)
@@ -51,4 +51,5 @@
 import org.openstreetmap.josm.tools.I18n;
 import org.openstreetmap.josm.tools.ImageProvider;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -292,6 +293,5 @@
                 System.out.println("Reading preferences from " + i);
                 try {
-                    URL url = new URL(i);
-                    config.openAndReadXML(url.openStream());
+                    config.openAndReadXML(Utils.openURL(new URL(i)));
                 } catch (Exception ex) {
                     throw new RuntimeException(ex);
Index: /trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java	(revision 5868)
@@ -21,11 +21,6 @@
  * It also has to be <strong>transformed</strong> because the internal help browser required slightly
  * different HTML than what is provided by the Wiki.
- *
- * @see WikiReader
  */
-public class HelpContentReader {
-
-    /** the base url */
-    private String baseUrl;
+public class HelpContentReader extends WikiReader {
 
     /**
@@ -35,5 +30,5 @@
      */
     public HelpContentReader(String baseUrl) {
-        this.baseUrl = baseUrl;
+        super(baseUrl);
     }
 
@@ -90,57 +85,13 @@
      */
     protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException {
-        boolean isInContent = false;
-        boolean isInTranslationsSideBar = false;
-        boolean isExistingHelpPage = false;
-        StringBuffer sball = new StringBuffer();
-        StringBuffer sb = new StringBuffer();
+        String s = "";
         try {
-            for (String line = in.readLine(); line != null; line = in.readLine()) {
-                sball.append(line);
-                sball.append("\n");
-                if (line.contains("<div id=\"searchable\">")) {
-                    isInContent = true;
-                } else if (line.contains("<div class=\"wiki-toc trac-nav\"")) {
-                    isInTranslationsSideBar = true;
-                } else if (line.contains("<div class=\"wikipage searchable\">")) {
-                    isInContent = true;
-                } else if (line.contains("<div class=\"buttons\">")) {
-                    isInContent = false;
-                } else if (line.contains("<h3>Attachments</h3>")) {
-                    isInContent = false;
-                } else if (line.contains("<div id=\"attachments\">")) {
-                    isInContent = false;
-                } else if (line.contains("<div class=\"trac-modifiedby\">")) {
-                    continue;
-                } else if (line.contains("<input type=\"submit\" name=\"attachfilebutton\"")) {
-                    // heuristic: if we find a button for uploading images we are in an
-                    // existing pages. Otherwise this is probably the stub page for a not yet
-                    // existing help page
-                    isExistingHelpPage = true;
-                }
-                if (isInContent && !isInTranslationsSideBar) {
-                    // add a border="0" attribute to images, otherwise the internal help browser
-                    // will render a thick  border around images inside an <a> element
-                    //
-                    // Also make sure image URLs are absolute
-                    //
-                    line = line.replaceAll("<img ([^>]*)src=\"/", "<img border=\"0\" \\1src=\"" + baseUrl + "/").replaceAll("href=\"/",
-                            "href=\"" + baseUrl + "/").replaceAll(" />", ">");
-                    sb.append(line);
-                    sb.append("\n");
-                } else if (isInTranslationsSideBar && line.contains("</div>")) {
-                    isInTranslationsSideBar = false;
-                }
-            }
+            s = readFromTrac(in);
         } catch(IOException e) {
             throw new HelpContentReaderException(e);
         }
-        if(!dotest && sb.length() == 0)
-            sb = sball;
-        else if (dotest && !isExistingHelpPage)
+        if(dotest && s.isEmpty())
             throw new MissingHelpContentException();
-        sb.insert(0, "<html>");
-        sb.append("<html>");
-        return sb.toString();
+        return s;
     }
 }
Index: /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java	(revision 5868)
@@ -77,4 +77,5 @@
 import org.openstreetmap.josm.io.OsmTransferException;
 import org.openstreetmap.josm.io.UTFInputStreamReader;
+import org.openstreetmap.josm.tools.Utils;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -321,5 +322,5 @@
             protected byte[] updateData() throws IOException {
                 URL u = getAttributionUrl();
-                UTFInputStreamReader in = UTFInputStreamReader.create(u.openStream(), "utf-8");
+                UTFInputStreamReader in = UTFInputStreamReader.create(Utils.openURL(u), "utf-8");
                 String r = new Scanner(in).useDelimiter("\\A").next();
                 in.close();
Index: /trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java	(revision 5868)
@@ -71,8 +71,5 @@
             } else {
                 if (Main.applet) {
-                    URLConnection conn = url.openConnection();
-                    conn.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000);
-                    conn.setReadTimeout(Main.pref.getInteger("socket.timeout.read",30)*1000);
-                    fs = new BufferedInputStream(conn.getInputStream());
+                    fs = new BufferedInputStream(Utils.openURL(url));
                     file = new File(url.getFile());
                 } else {
Index: /trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 5868)
@@ -10,7 +10,9 @@
 import java.awt.datatransfer.Transferable;
 import java.awt.datatransfer.UnsupportedFlavorException;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.io.OutputStream;
 import java.io.Reader;
@@ -18,4 +20,5 @@
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.net.URLConnection;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
@@ -28,4 +31,5 @@
 import java.util.List;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Version;
 
@@ -554,7 +558,34 @@
         }
         HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
+        connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString());
         return connection;
     }
     
+    /**
+     * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
+     * @param url The url to open
+     * @return An stream for the given URL
+     * @throws IOException if an I/O exception occurs.
+     * @since 5867
+     */
+    public static InputStream openURL(URL url) throws IOException {
+        URLConnection connection = url.openConnection();
+        connection.setRequestProperty("User-Agent", Version.getInstance().getFullAgentString());
+        connection.setConnectTimeout(Main.pref.getInteger("socket.timeout.connect",15)*1000);
+        connection.setReadTimeout(Main.pref.getInteger("socket.timeout.read",30)*1000);
+        return connection.getInputStream();
+    }
+
+    /**
+     * Opens a connection to the given URL and sets the User-Agent property to JOSM's one.
+     * @param url The url to open
+     * @return An buffered stream reader for the given URL (using UTF-8)
+     * @throws IOException if an I/O exception occurs.
+     * @since 5867
+     */
+    public static BufferedReader openURLReader(URL url) throws IOException {
+        return new BufferedReader(new InputStreamReader(openURL(url), "utf-8"));
+    }
+
     /**
      * Opens a HTTP connection to the given URL, sets the User-Agent property to JOSM's one and optionnaly disables Keep-Alive.
Index: /trunk/src/org/openstreetmap/josm/tools/WikiReader.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 5867)
+++ /trunk/src/org/openstreetmap/josm/tools/WikiReader.java	(revision 5868)
@@ -5,5 +5,4 @@
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.net.URL;
 
@@ -36,5 +35,5 @@
      */
     public String read(String url) throws IOException {
-        BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "utf-8"));
+        BufferedReader in = Utils.openURLReader(new URL(url));
         try {
             if (url.startsWith(baseurl) && !url.endsWith("?format=txt"))
@@ -60,7 +59,7 @@
 
     private String readLang(URL url) throws IOException {
-        InputStream in = url.openStream();
+        BufferedReader in = Utils.openURLReader(url);
         try {
-            return readFromTrac(new BufferedReader(new InputStreamReader(in, "utf-8")));
+            return readFromTrac(in);
         } finally {
             in.close();
@@ -78,5 +77,5 @@
     }
 
-    private String readFromTrac(BufferedReader in) throws IOException {
+    protected String readFromTrac(BufferedReader in) throws IOException {
         boolean inside = false;
         boolean transl = false;
