Skip to content

Commit

Permalink
Merge pull request #5078 from kwvanderlinde/bugfix/5077-external-url-…
Browse files Browse the repository at this point in the history
…hang

Fix threading issue with external links in HTML5 contexts
  • Loading branch information
cwisniew authored Dec 6, 2024
2 parents 36c5b4f + 9850eda commit 3715c8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/main/java/net/rptools/maptool/client/MapTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,20 +480,24 @@ public static BackupManager getBackupManager() {
* be called from any uncontrolled macros as there are both security and denial-of-service attacks
* possible.
*
* <p>This should not be called from any uncontrolled macros as there are both security and
* denial-of-service attacks possible.
*
* <p>This must be called on the AWT thread.
*
* @param url the URL to pass to the browser.
*/
public static void showDocument(String url) {
if (Desktop.isDesktopSupported()) {
String lowerCaseUrl = url.toLowerCase();
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
String urlToBrowse = url;
Desktop desktop = Desktop.getDesktop();
URI uri = null;
try {
uri = new URI(urlToBrowse);
if (uri.getScheme() == null) {
urlToBrowse = "https://" + urlToBrowse;
uri = new URI(urlToBrowse);
}
uri = new URI(urlToBrowse);
desktop.browse(uri);
} catch (Exception e) {
MapTool.showError(I18N.getText("msg.error.browser.cannotStart", uri), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,8 @@ private void fixHref(org.w3c.dom.events.Event event) {
// Java bug JDK-8199014 workaround
webEngine.executeScript(String.format(SCRIPT_ANCHOR, href.substring(1)));
} else if (!href2.startsWith("javascript")) {
// non-macrolink, non-anchor link, non-javascript code
MapTool.showDocument(href); // show in usual browser
// non-macrolink, non-anchor link, non-javascript code. Show in usual browser
SwingUtilities.invokeLater(() -> MapTool.showDocument(href));
}
event.preventDefault(); // don't change webview
}
Expand Down

0 comments on commit 3715c8e

Please sign in to comment.