Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -152,7 +151,7 @@ private static URI resolveURI(IConfigurationElement element) {
ILog.get().warn("A URL object was not found for the given URI " + uri + " from " + contributorName);
return null;
}
} catch (InvalidRegistryObjectException | URISyntaxException | MalformedURLException e) {
} catch (InvalidRegistryObjectException | URISyntaxException e) {
ILog.get().error(e.getMessage(), e);
return null;
}
Expand Down Expand Up @@ -199,9 +198,9 @@ private static URI resolveURI(IConfigurationElement element) {
*
* @param url URL to convert
* @return converted URI
* @throws MalformedURLException Error creating a
* @throws URISyntaxException if the URL can't be converted to a URI
*/
private static URI convertToURI(URL url) throws URISyntaxException, MalformedURLException {
private static URI convertToURI(URL url) throws URISyntaxException {
if ("file".equals(url.getProtocol())) {
return new URI(url.getProtocol(), url.getAuthority(), url.getPath(), null, null);
}
Expand All @@ -222,9 +221,10 @@ private static URI convertToURI(URL url) throws URISyntaxException, MalformedURL
jarURLString = jarURLString.substring(0, startEntry);
}

// convert JAR-URL
URL jarURL = new URL(jarURLString);
URI jarURI = convertToURI(jarURL);
// convert JAR-URL, quoting the characters that are not valid in a URI
URI jarURI = jarURLString.startsWith("file:")
? new URI("file", null, jarURLString.substring("file:".length()), null)
: new URI(jarURLString);

// build URI with valid JAR-URL by replacing the URL of the JAR with the valid
// one
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020 EclipseSource and others.
* Copyright (c) 2020, 2026 EclipseSource and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -11,8 +11,8 @@

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.Set;

Expand Down Expand Up @@ -200,20 +200,26 @@ private boolean validateDialog() {
}

String schemaLocation;
String location = schemaLocationData.getText();
try {
URL locationURL = new URL(schemaLocationData.getText());
if (locationURL.getProtocol().equals("file")) {
File file = new File(locationURL.getPath());
if (location.regionMatches(true, 0, "file:", 0, "file:".length())) {
// Browse fills in "file://" followed by the plain absolute path, which may
// contain characters that are not valid in a URI (e.g. spaces), so the path
// is taken as is instead of being parsed as URI.
File file = new File(location.substring("file:".length()).replaceFirst("^//", ""));
if (file.exists()) {
schemaLocation = "file://" + file.getAbsolutePath();
} else {
setErrorMessage(SchemaAssociationsMessages.SchemaAssociationDialog_Error_SchemaLocation_invalid);
return updateOkButton(false);
}
} else {
schemaLocation = locationURL.toURI().toString();
URI locationURI = new URI(location);
// Check that the URI is absolute and its scheme is supported
locationURI.toURL();
schemaLocation = locationURI.toString();
}
} catch (MalformedURLException | URISyntaxException | NullPointerException e) {
} catch (MalformedURLException | URISyntaxException | IllegalArgumentException e) {
setErrorMessage(SchemaAssociationsMessages.SchemaAssociationDialog_Error_SchemaLocation_invalid);
return updateOkButton(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 Red Hat Inc. and others.
* Copyright (c) 2021, 2026 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -10,7 +10,7 @@
package org.eclipse.wildwebdeveloper;

import java.io.IOException;
import java.net.URL;
import java.net.URI;

import org.eclipse.core.runtime.FileLocator;

Expand All @@ -20,8 +20,8 @@ private SchemaAssociationRegistry() {}

public static String translate(String url) {
try {
return FileLocator.toFileURL(new URL(url)).toString();
} catch (IOException e) {
return FileLocator.toFileURL(URI.create(url).toURL()).toString();
} catch (IOException | IllegalArgumentException e) {
return url;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2018, 2023 Red Hat Inc. and others.
* Copyright (c) 2018, 2026 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand All @@ -17,7 +17,8 @@

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.text.MessageFormat;

import org.eclipse.core.resources.IFile;
Expand Down Expand Up @@ -423,8 +424,8 @@ private void validateProgramPathAndURL() {

} else if (urlRadio.getSelection()) {
try {
new URL(urlText.getText());
} catch (MalformedURLException ex) {
new URI(urlText.getText()).toURL();
} catch (MalformedURLException | URISyntaxException | IllegalArgumentException ex) {
errorMessage = MessageFormat.format(
Messages.RunProgramTab_error_malformedUR,
ex.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package org.eclipse.wildwebdeveloper.eslint;

import java.io.File;
import java.net.URL;
import java.net.URI;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -118,7 +118,7 @@ public CompletableFuture<Void> openDoc(Map<String,String> data) {
Display.getDefault().asyncExec(() -> {
IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
try {
browserSupport.createBrowser("openDoc").openURL(new URL(data.get("url")));
browserSupport.createBrowser("openDoc").openURL(URI.create(data.get("url")).toURL());
} catch (Exception e) {
ILog.get().error(e.getMessage(), e);
}
Expand Down
Loading