Ticket #23688: at_localhost.patch
| File at_localhost.patch, 1.8 KB (added by , 18 months ago) |
|---|
-
src/org/openstreetmap/josm/plugins/utilsplugin2/customurl/OpenPageAction.java
6 6 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.KeyEvent; 9 import java.io.IOException; 9 10 import java.io.UnsupportedEncodingException; 10 11 import java.net.URLEncoder; 12 import java.net.HttpURLConnection; 13 import java.net.URL; 11 14 import java.util.Collection; 12 15 import java.util.regex.Matcher; 13 16 import java.util.regex.Pattern; … … 97 100 for (int j = 0; j < i; j++) { 98 101 addr = addr.replace(keys[j], vals[j]); 99 102 } 103 104 // Opened on the local system instead of the browser: http://127.0.0.1:<port>/script@localhost 105 Pattern pat_direct = Pattern.compile("(http.*)@localhost$"); 106 Matcher m_direct = pat_direct.matcher(addr); 107 100 108 try { 109 if (m_direct.find()) { 110 addr = m_direct.group(1); // replace addr so possible error uses it 111 Logging.info("Opening on the local system: " + addr); 112 URL url = new URL(addr); 113 HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); 114 urlConn.setRequestMethod("GET"); 115 if (urlConn.getResponseCode() != HttpURLConnection.HTTP_OK) { 116 throw new IOException(". GET response:" + urlConn.getResponseCode()); 117 } 118 101 119 // See #12836 - do not load invalid history 102 if (!addr.endsWith("/0/history")) {120 } else if (!addr.endsWith("/0/history")) { 103 121 OpenBrowser.displayUrl(addr); 104 122 } 105 123 } catch (Exception ex) {
