Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix threading issue with external links in HTML5 contexts #5078

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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