mirror of
https://github.com/octoleo/plantuml.git
synced 2024-11-25 14:27:33 +00:00
commit
11b70de43f
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,6 +7,9 @@
|
||||
*.iml
|
||||
out
|
||||
|
||||
#vscode files
|
||||
/bin
|
||||
|
||||
# Ant result file
|
||||
plantuml.jar
|
||||
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -48,7 +48,7 @@ import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.sourceforge.plantuml.log.Logme;
|
||||
@ -140,7 +140,7 @@ public class Splash extends Window implements MouseListener, MouseMotionListener
|
||||
public void mouseClicked(MouseEvent event) {
|
||||
if (link != LINK_NORMAL) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URL("https://plantuml.com").toURI());
|
||||
Desktop.getDesktop().browse(new URI("https://plantuml.com"));
|
||||
} catch (Exception e) {
|
||||
Logme.error(e);
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
@ -141,8 +143,8 @@ public class SURL {
|
||||
|
||||
if (url.startsWith("http://") || url.startsWith("https://"))
|
||||
try {
|
||||
return create(new URL(url));
|
||||
} catch (MalformedURLException e) {
|
||||
return create(new URI(url).toURL());
|
||||
} catch (MalformedURLException | URISyntaxException e) {
|
||||
Logme.error(e);
|
||||
}
|
||||
return null;
|
||||
@ -156,8 +158,9 @@ public class SURL {
|
||||
* @param url
|
||||
* @return the secure URL
|
||||
* @throws MalformedURLException if <code>url</code> is null
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
public static SURL create(URL url) throws MalformedURLException {
|
||||
public static SURL create(URL url) throws MalformedURLException, URISyntaxException {
|
||||
if (url == null)
|
||||
throw new MalformedURLException("URL cannot be null");
|
||||
|
||||
@ -268,8 +271,9 @@ public class SURL {
|
||||
* @param url plain URL
|
||||
* @return SURL without any user credential information.
|
||||
* @throws MalformedURLException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
static SURL createWithoutUser(URL url) throws MalformedURLException {
|
||||
static SURL createWithoutUser(URL url) throws MalformedURLException, URISyntaxException {
|
||||
return new SURL(removeUserInfo(url), WITHOUT_AUTHENTICATION);
|
||||
}
|
||||
|
||||
@ -481,14 +485,14 @@ public class SURL {
|
||||
return http;
|
||||
}
|
||||
|
||||
public byte[] call() throws IOException {
|
||||
public byte[] call() throws IOException, URISyntaxException {
|
||||
HttpURLConnection http = openConnection(url);
|
||||
final int responseCode = http.getResponseCode();
|
||||
|
||||
if (responseCode == HttpURLConnection.HTTP_MOVED_TEMP
|
||||
|| responseCode == HttpURLConnection.HTTP_MOVED_PERM) {
|
||||
final String newUrl = http.getHeaderField("Location");
|
||||
http = openConnection(new URL(newUrl));
|
||||
http = openConnection(new URI(newUrl).toURL());
|
||||
}
|
||||
|
||||
return retrieveResponseAsBytes(http);
|
||||
@ -679,9 +683,10 @@ public class SURL {
|
||||
* @param url URL with UserInfo part
|
||||
* @return url without UserInfo part
|
||||
* @throws MalformedURLException
|
||||
* @throws URISyntaxException
|
||||
*/
|
||||
private static URL removeUserInfo(URL url) throws MalformedURLException {
|
||||
return new URL(removeUserInfoFromUrlPath(url.toExternalForm()));
|
||||
private static URL removeUserInfo(URL url) throws MalformedURLException, URISyntaxException {
|
||||
return new URI(removeUserInfoFromUrlPath(url.toExternalForm())).toURL();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,7 @@ import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.stream.MemoryCacheImageInputStream;
|
||||
@ -310,7 +310,7 @@ public class PicoWebServerTest {
|
||||
}
|
||||
|
||||
private static HttpURLConnection urlConnection(String path) throws Exception {
|
||||
final HttpURLConnection conn = (HttpURLConnection) new URL("http://localhost:" + port + path).openConnection();
|
||||
final HttpURLConnection conn = (HttpURLConnection) new URI("http://localhost:" + port + path).toURL().openConnection();
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
return conn;
|
||||
}
|
||||
|
@ -4,7 +4,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -66,6 +67,7 @@ class SURLTest {
|
||||
* Checks a SURL after removing the UserInfo part.
|
||||
*
|
||||
* @throws MalformedURLException this should not be happened
|
||||
* @throws URISyntaxException should not happen
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
@ -75,8 +77,8 @@ class SURLTest {
|
||||
"https://localhost:8080/api",
|
||||
"https://alice@localhost:8080/api",
|
||||
"https://alice_secret@localhost:8080/api"})
|
||||
void removeUserInfo(String url) throws MalformedURLException {
|
||||
SURL surl = SURL.createWithoutUser(new URL(url));
|
||||
void removeUserInfo(String url) throws MalformedURLException, URISyntaxException {
|
||||
SURL surl = SURL.createWithoutUser(new URI(url).toURL());
|
||||
|
||||
assertThat(surl).isNotNull();
|
||||
assertThat(surl.isAuthorizationConfigured()).isFalse();
|
||||
|
Loading…
Reference in New Issue
Block a user