Merge branch '3.1.x'

Closes gh-38878
This commit is contained in:
Phillip Webb
2023-12-19 23:10:49 -08:00
6 changed files with 32 additions and 16 deletions

View File

@@ -20,12 +20,12 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Constructor;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -225,9 +225,9 @@ public class PropertiesLauncher extends Launcher {
return getFileResource(config);
}
private String handleUrl(String path) throws UnsupportedEncodingException {
private String handleUrl(String path) {
if (path.startsWith("jar:file:") || path.startsWith("file:")) {
path = URLDecoder.decode(path, "UTF-8");
path = URLDecoder.decode(path, StandardCharsets.UTF_8);
if (path.startsWith("file:")) {
path = path.substring("file:".length());
if (path.startsWith("//")) {

View File

@@ -20,12 +20,12 @@ import java.io.ByteArrayOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.net.URLStreamHandler;
import java.nio.charset.StandardCharsets;
import java.security.Permission;
/**
@@ -318,13 +318,8 @@ final class JarURLConnection extends java.net.JarURLConnection {
for (int i = 0; i < length; i++) {
int c = source.charAt(i);
if (c > 127) {
try {
String encoded = URLEncoder.encode(String.valueOf((char) c), "UTF-8");
write(encoded, outputStream);
}
catch (UnsupportedEncodingException ex) {
throw new IllegalStateException(ex);
}
String encoded = URLEncoder.encode(String.valueOf((char) c), StandardCharsets.UTF_8);
write(encoded, outputStream);
}
else {
if (c == '%') {