Changeset 5936 in josm for trunk/src/org


Ignore:
Timestamp:
2013-05-07T13:46:58+02:00 (11 years ago)
Author:
stoecker
Message:

fix #8685 - wiki browser links not working

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/help/HelpContentReader.java

    r5915 r5936  
    4747        BufferedReader in = null;
    4848        try {
    49             con = Utils.openHttpConnection(new URL(helpTopicUrl));
     49            URL u = new URL(helpTopicUrl);
     50            con = Utils.openHttpConnection(u);
    5051            con.connect();
    5152            in = new BufferedReader(new InputStreamReader(con.getInputStream(),"utf-8"));
    52             return prepareHelpContent(in, dotest);
     53            return prepareHelpContent(in, dotest, u);
    5354        } catch(MalformedURLException e) {
    5455            throw new HelpContentReaderException(e);
     
    7980     * @throws HelpContentReaderException thrown if an exception occurs
    8081     * @throws MissingHelpContentException thrown, if the content read isn't a help page
     82     * @since 5935
    8183     */
    82     protected String prepareHelpContent(BufferedReader in, boolean dotest) throws HelpContentReaderException {
     84    protected String prepareHelpContent(BufferedReader in, boolean dotest, URL url) throws HelpContentReaderException {
    8385        String s = "";
    8486        try {
    85             s = readFromTrac(in);
     87            s = readFromTrac(in, url);
    8688        } catch(IOException e) {
    8789            throw new HelpContentReaderException(e);
  • trunk/src/org/openstreetmap/josm/tools/WikiReader.java

    r5915 r5936  
    3535     */
    3636    public String read(String url) throws IOException {
    37         BufferedReader in = Utils.openURLReader(new URL(url));
     37        URL u = new URL(url);
     38        BufferedReader in = Utils.openURLReader(u);
    3839        try {
    3940            if (url.startsWith(baseurl) && !url.endsWith("?format=txt"))
    40                 return readFromTrac(in);
     41                return readFromTrac(in, u);
    4142            return readNormal(in);
    4243        } finally {
     
    7879        BufferedReader in = Utils.openURLReader(url);
    7980        try {
    80             return readFromTrac(in);
     81            return readFromTrac(in, url);
    8182        } finally {
    8283            Utils.close(in);
     
    9495    }
    9596
    96     protected String readFromTrac(BufferedReader in) throws IOException {
     97    protected String readFromTrac(BufferedReader in, URL url) throws IOException {
    9798        boolean inside = false;
    9899        boolean transl = false;
     
    119120                // will render a thick  border around images inside an <a> element
    120121                //
    121                 b += line.replaceAll("<img ", "<img border=\"0\" ").replaceAll(" />", ">") + "\n";
     122                b += line.replaceAll("<img ", "<img border=\"0\" ")
     123                         .replaceAll("href=\"/", "href=\"" + baseurl + "/")
     124                         .replaceAll(" />", ">")
     125                         + "\n";
    122126            } else if (transl && line.contains("</div>")) {
    123127                transl = false;
     
    130134        || b.indexOf(" does not exist. You can create it here.</p>") >= 0)
    131135            return "";
    132         return "<html><base href=\""+baseurl+"\"> " + b + "</html>";
     136        return "<html><base href=\""+url.toExternalForm() +"\"> " + b + "</html>";
    133137    }
    134138}
Note: See TracChangeset for help on using the changeset viewer.