Skip to content

Commit b2e77ea

Browse files
committed
Merge
2 parents 90bd1ac + 54f2095 commit b2e77ea

File tree

18 files changed

+280
-85
lines changed

18 files changed

+280
-85
lines changed

src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2009, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,6 @@
2424
*/
2525
package sun.net.ftp.impl;
2626

27-
28-
2927
import java.io.BufferedInputStream;
3028
import java.io.BufferedOutputStream;
3129
import java.io.BufferedReader;
@@ -64,13 +62,15 @@
6462
import java.util.regex.Pattern;
6563
import javax.net.ssl.SSLSocket;
6664
import javax.net.ssl.SSLSocketFactory;
65+
6766
import sun.net.ftp.FtpDirEntry;
6867
import sun.net.ftp.FtpDirParser;
6968
import sun.net.ftp.FtpProtocolException;
7069
import sun.net.ftp.FtpReplyCode;
7170
import sun.net.util.IPAddressUtil;
7271
import sun.util.logging.PlatformLogger;
7372

73+
import static sun.net.util.ProxyUtil.copyProxy;
7474

7575
public class FtpClient extends sun.net.ftp.FtpClient {
7676

@@ -982,7 +982,7 @@ public int getReadTimeout() {
982982
}
983983

984984
public sun.net.ftp.FtpClient setProxy(Proxy p) {
985-
proxy = p;
985+
proxy = copyProxy(p);
986986
return this;
987987
}
988988

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
package sun.net.util;
27+
28+
import sun.net.ApplicationProxy;
29+
30+
import java.net.Proxy;
31+
32+
public final class ProxyUtil {
33+
34+
private ProxyUtil() {}
35+
36+
/**
37+
* Creates a new {@link Proxy} instance for the given proxy iff it is
38+
* neither null, {@link Proxy#NO_PROXY Proxy.NO_PROXY}, an
39+
* {@link ApplicationProxy} instance, nor already a {@code Proxy} instance.
40+
*/
41+
public static Proxy copyProxy(Proxy proxy) {
42+
return proxy == null
43+
|| proxy.getClass() == Proxy.class
44+
|| proxy instanceof ApplicationProxy
45+
? proxy
46+
: new Proxy(proxy.type(), proxy.address());
47+
}
48+
49+
}

src/java.base/share/classes/sun/net/www/http/HttpClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -41,6 +41,8 @@
4141
import sun.net.www.protocol.http.AuthCacheImpl;
4242
import sun.net.www.protocol.http.HttpURLConnection;
4343
import sun.util.logging.PlatformLogger;
44+
45+
import static sun.net.util.ProxyUtil.copyProxy;
4446
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
4547
import sun.security.action.GetPropertyAction;
4648

@@ -267,7 +269,7 @@ public HttpClient(URL url, String proxyHost, int proxyPort)
267269
}
268270

269271
protected HttpClient(URL url, Proxy p, int to) throws IOException {
270-
proxy = (p == null) ? Proxy.NO_PROXY : p;
272+
proxy = p == null ? Proxy.NO_PROXY : copyProxy(p);
271273
this.host = url.getHost();
272274
this.url = url;
273275
port = url.getPort();
@@ -332,9 +334,7 @@ public static HttpClient New(URL url, boolean useCache)
332334
public static HttpClient New(URL url, Proxy p, int to, boolean useCache,
333335
HttpURLConnection httpuc) throws IOException
334336
{
335-
if (p == null) {
336-
p = Proxy.NO_PROXY;
337-
}
337+
p = p == null ? Proxy.NO_PROXY : copyProxy(p);
338338
HttpClient ret = null;
339339
/* see if one's already around */
340340
if (useCache) {

src/java.base/share/classes/sun/net/www/protocol/ftp/FtpURLConnection.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@
4848
import java.util.StringTokenizer;
4949
import java.security.Permission;
5050
import java.util.Properties;
51+
5152
import sun.net.NetworkClient;
5253
import sun.net.util.IPAddressUtil;
5354
import sun.net.www.MessageHeader;
@@ -59,6 +60,7 @@
5960
import sun.net.www.ParseUtil;
6061
import sun.security.action.GetPropertyAction;
6162

63+
import static sun.net.util.ProxyUtil.copyProxy;
6264

6365
/**
6466
* This class Opens an FTP input (or output) stream given a URL.
@@ -246,7 +248,7 @@ public ProxySelector run() {
246248
throw new IOException("Failed to select a proxy", iae);
247249
}
248250
for (Proxy proxy : proxies) {
249-
p = proxy;
251+
p = copyProxy(proxy);
250252
if (p == null || p == Proxy.NO_PROXY ||
251253
p.type() == Proxy.Type.SOCKS) {
252254
break;

src/java.base/share/classes/sun/net/www/protocol/ftp/Handler.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,11 +33,9 @@
3333
import java.net.MalformedURLException;
3434
import java.net.URL;
3535
import java.net.Proxy;
36-
import java.util.Map;
37-
import java.util.HashMap;
3836
import java.util.Objects;
39-
import sun.net.ftp.FtpClient;
40-
import sun.net.www.protocol.http.HttpURLConnection;
37+
38+
import static sun.net.util.ProxyUtil.copyProxy;
4139

4240
/** open an ftp connection given a URL */
4341
public class Handler extends java.net.URLStreamHandler {
@@ -57,11 +55,11 @@ protected java.net.URLConnection openConnection(URL u)
5755
return openConnection(u, null);
5856
}
5957

60-
protected java.net.URLConnection openConnection(URL u, Proxy p)
58+
protected java.net.URLConnection openConnection(URL u, Proxy proxy)
6159
throws IOException {
62-
FtpURLConnection connection = null;
60+
FtpURLConnection connection;
6361
try {
64-
connection = new FtpURLConnection(u, p);
62+
connection = new FtpURLConnection(u, copyProxy(proxy));
6563
} catch (IllegalArgumentException e) {
6664
var mfue = new MalformedURLException(e.getMessage());
6765
mfue.initCause(e);

src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1995, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -84,6 +84,7 @@
8484
import java.util.Properties;
8585
import java.util.concurrent.locks.ReentrantLock;
8686

87+
import static sun.net.util.ProxyUtil.copyProxy;
8788
import static sun.net.www.protocol.http.AuthScheme.BASIC;
8889
import static sun.net.www.protocol.http.AuthScheme.DIGEST;
8990
import static sun.net.www.protocol.http.AuthScheme.NTLM;
@@ -935,7 +936,7 @@ protected HttpURLConnection(URL u, Proxy p, Handler handler)
935936
responses = new MessageHeader(maxHeaderSize);
936937
userHeaders = new MessageHeader();
937938
this.handler = handler;
938-
instProxy = p;
939+
instProxy = copyProxy(p);
939940
if (instProxy instanceof sun.net.ApplicationProxy) {
940941
/* Application set Proxies should not have access to cookies
941942
* in a secure environment unless explicitly allowed. */
@@ -1250,7 +1251,7 @@ public ProxySelector run() {
12501251
final Iterator<Proxy> it = proxies.iterator();
12511252
Proxy p;
12521253
while (it.hasNext()) {
1253-
p = it.next();
1254+
p = copyProxy(it.next());
12541255
try {
12551256
if (!failedOnce) {
12561257
http = getNewHttpClient(url, p, connectTimeout);

src/java.base/share/classes/sun/security/ssl/CertificateMessage.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1129,6 +1129,15 @@ public void consume(ConnectionContext context,
11291129

11301130
// clean up this consumer
11311131
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1132+
1133+
// Ensure that the Certificate message has not been sent w/o
1134+
// an EncryptedExtensions preceding
1135+
if (hc.handshakeConsumers.containsKey(
1136+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1137+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1138+
"Unexpected Certificate handshake message");
1139+
}
1140+
11321141
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11331142
if (hc.sslConfig.isClientMode) {
11341143
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {

src/java.base/share/classes/sun/security/ssl/CertificateVerify.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1163,6 +1163,14 @@ public void consume(ConnectionContext context,
11631163
// Clean up this consumer
11641164
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11651165

1166+
// Ensure that the Certificate Verify message has not been sent w/o
1167+
// a Certificate message preceding
1168+
if (hc.handshakeConsumers.containsKey(
1169+
SSLHandshake.CERTIFICATE.id)) {
1170+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1171+
"Unexpected Certificate Verify handshake message");
1172+
}
1173+
11661174
T13CertificateVerifyMessage cvm =
11671175
new T13CertificateVerifyMessage(hc, message);
11681176
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {

src/java.base/share/classes/sun/security/ssl/Finished.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -900,6 +900,14 @@ public void consume(ConnectionContext context,
900900

901901
private void onConsumeFinished(ClientHandshakeContext chc,
902902
ByteBuffer message) throws IOException {
903+
// Ensure that the Finished message has not been sent w/o
904+
// an EncryptedExtensions preceding
905+
if (chc.handshakeConsumers.containsKey(
906+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
907+
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
908+
"Unexpected Finished handshake message");
909+
}
910+
903911
// Make sure that any expected CertificateVerify message
904912
// has been received and processed.
905913
if (!chc.isResumption) {

src/java.desktop/macosx/classes/com/apple/laf/AquaTabbedPaneCopyFromBasicUI.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -404,7 +404,11 @@ protected void installListeners() {
404404
}
405405
tabPane.addContainerListener(getHandler());
406406
if (tabPane.getTabCount() > 0) {
407-
htmlViews = createHTMLVector();
407+
Boolean htmlDisabled = (Boolean)
408+
tabPane.getClientProperty("html.disable");
409+
if (!(Boolean.TRUE.equals(htmlDisabled))) {
410+
htmlViews = createHTMLVector();
411+
}
408412
}
409413
}
410414

@@ -3445,8 +3449,10 @@ public void componentAdded(final ContainerEvent e) {
34453449

34463450
private void updateHtmlViews(int index, boolean inserted) {
34473451
final String title = tabPane.getTitleAt(index);
3452+
Boolean htmlDisabled = (Boolean)
3453+
tabPane.getClientProperty("html.disable");
34483454
final boolean isHTML = BasicHTML.isHTMLString(title);
3449-
if (isHTML) {
3455+
if (isHTML && !(Boolean.TRUE.equals(htmlDisabled))) {
34503456
if (htmlViews == null) { // Initialize vector
34513457
htmlViews = createHTMLVector();
34523458
} else { // Vector already exists

0 commit comments

Comments
 (0)