Skip to content

Commit 626cb3b

Browse files
committed
Merge
2 parents 315ea00 + 141d7af commit 626cb3b

File tree

21 files changed

+352
-95
lines changed

21 files changed

+352
-95
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009, 2017, 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,7 +24,6 @@
2424
*/
2525
package sun.net.ftp.impl;
2626

27-
2827
import java.io.BufferedInputStream;
2928
import java.io.BufferedOutputStream;
3029
import java.io.BufferedReader;
@@ -62,13 +61,15 @@
6261
import java.util.regex.Pattern;
6362
import javax.net.ssl.SSLSocket;
6463
import javax.net.ssl.SSLSocketFactory;
64+
6565
import sun.net.ftp.FtpDirEntry;
6666
import sun.net.ftp.FtpDirParser;
6767
import sun.net.ftp.FtpProtocolException;
6868
import sun.net.ftp.FtpReplyCode;
6969
import sun.net.util.IPAddressUtil;
7070
import sun.util.logging.PlatformLogger;
7171

72+
import static sun.net.util.ProxyUtil.copyProxy;
7273

7374
public class FtpClient extends sun.net.ftp.FtpClient {
7475

@@ -996,7 +997,7 @@ public int getReadTimeout() {
996997
}
997998

998999
public sun.net.ftp.FtpClient setProxy(Proxy p) {
999-
proxy = p;
1000+
proxy = copyProxy(p);
10001001
return this;
10011002
}
10021003

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, 2019, 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
@@ -40,6 +40,8 @@
4040
import sun.net.www.protocol.http.AuthenticatorKeys;
4141
import sun.net.www.protocol.http.HttpURLConnection;
4242
import sun.util.logging.PlatformLogger;
43+
44+
import static sun.net.util.ProxyUtil.copyProxy;
4345
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
4446
import sun.security.action.GetPropertyAction;
4547

@@ -264,7 +266,7 @@ public HttpClient(URL url, String proxyHost, int proxyPort)
264266
}
265267

266268
protected HttpClient(URL url, Proxy p, int to) throws IOException {
267-
proxy = (p == null) ? Proxy.NO_PROXY : p;
269+
proxy = p == null ? Proxy.NO_PROXY : copyProxy(p);
268270
this.host = url.getHost();
269271
this.url = url;
270272
port = url.getPort();
@@ -329,9 +331,7 @@ public static HttpClient New(URL url, boolean useCache)
329331
public static HttpClient New(URL url, Proxy p, int to, boolean useCache,
330332
HttpURLConnection httpuc) throws IOException
331333
{
332-
if (p == null) {
333-
p = Proxy.NO_PROXY;
334-
}
334+
p = p == null ? Proxy.NO_PROXY : copyProxy(p);
335335
HttpClient ret = null;
336336
/* see if one's already around */
337337
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, 2019, 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.Iterator;
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;
@@ -61,6 +62,7 @@
6162
import sun.net.www.ParseUtil;
6263
import sun.security.action.GetPropertyAction;
6364

65+
import static sun.net.util.ProxyUtil.copyProxy;
6466

6567
/**
6668
* This class Opens an FTP input (or output) stream given a URL.
@@ -244,7 +246,7 @@ public ProxySelector run() {
244246
URI uri = sun.net.www.ParseUtil.toURI(url);
245247
Iterator<Proxy> it = sel.select(uri).iterator();
246248
while (it.hasNext()) {
247-
p = it.next();
249+
p = copyProxy(it.next());
248250
if (p == null || p == Proxy.NO_PROXY ||
249251
p.type() == Proxy.Type.SOCKS) {
250252
break;

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1994, 2003, 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
@@ -32,10 +32,7 @@
3232
import java.io.IOException;
3333
import java.net.URL;
3434
import java.net.Proxy;
35-
import java.util.Map;
36-
import java.util.HashMap;
37-
import sun.net.ftp.FtpClient;
38-
import sun.net.www.protocol.http.HttpURLConnection;
35+
import static sun.net.util.ProxyUtil.copyProxy;
3936

4037
/** open an ftp connection given a URL */
4138
public class Handler extends java.net.URLStreamHandler {
@@ -56,8 +53,8 @@ protected java.net.URLConnection openConnection(URL u)
5653
return openConnection(u, null);
5754
}
5855

59-
protected java.net.URLConnection openConnection(URL u, Proxy p)
56+
protected java.net.URLConnection openConnection(URL u, Proxy proxy)
6057
throws IOException {
61-
return new FtpURLConnection(u, p);
58+
return new FtpURLConnection(u, copyProxy(proxy));
6259
}
6360
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1995, 2024, 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
@@ -81,6 +81,8 @@
8181
import java.nio.ByteBuffer;
8282
import java.util.Objects;
8383
import java.util.Properties;
84+
85+
import static sun.net.util.ProxyUtil.copyProxy;
8486
import static sun.net.www.protocol.http.AuthScheme.BASIC;
8587
import static sun.net.www.protocol.http.AuthScheme.DIGEST;
8688
import static sun.net.www.protocol.http.AuthScheme.NTLM;
@@ -898,7 +900,7 @@ protected HttpURLConnection(URL u, Proxy p, Handler handler)
898900
responses = new MessageHeader(maxHeaderSize);
899901
userHeaders = new MessageHeader();
900902
this.handler = handler;
901-
instProxy = p;
903+
instProxy = copyProxy(p);
902904
if (instProxy instanceof sun.net.ApplicationProxy) {
903905
/* Application set Proxies should not have access to cookies
904906
* in a secure environment unless explicitly allowed. */
@@ -1196,7 +1198,7 @@ public ProxySelector run() {
11961198
Iterator<Proxy> it = sel.select(uri).iterator();
11971199
Proxy p;
11981200
while (it.hasNext()) {
1199-
p = it.next();
1201+
p = copyProxy(it.next());
12001202
try {
12011203
if (!failedOnce) {
12021204
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, 2020, 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
@@ -1166,6 +1166,15 @@ public void consume(ConnectionContext context,
11661166

11671167
// clean up this consumer
11681168
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1169+
1170+
// Ensure that the Certificate message has not been sent w/o
1171+
// an EncryptedExtensions preceding
1172+
if (hc.handshakeConsumers.containsKey(
1173+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1174+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1175+
"Unexpected Certificate handshake message");
1176+
}
1177+
11691178
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11701179
if (hc.sslConfig.isClientMode) {
11711180
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, 2018, 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
@@ -1157,6 +1157,14 @@ public void consume(ConnectionContext context,
11571157
// Clean up this consumer
11581158
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11591159

1160+
// Ensure that the Certificate Verify message has not been sent w/o
1161+
// a Certificate message preceding
1162+
if (hc.handshakeConsumers.containsKey(
1163+
SSLHandshake.CERTIFICATE.id)) {
1164+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1165+
"Unexpected Certificate Verify handshake message");
1166+
}
1167+
11601168
T13CertificateVerifyMessage cvm =
11611169
new T13CertificateVerifyMessage(hc, message);
11621170
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, 2018, 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
@@ -881,6 +881,14 @@ public void consume(ConnectionContext context,
881881

882882
private void onConsumeFinished(ClientHandshakeContext chc,
883883
ByteBuffer message) throws IOException {
884+
// Ensure that the Finished message has not been sent w/o
885+
// an EncryptedExtensions preceding
886+
if (chc.handshakeConsumers.containsKey(
887+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
888+
throw chc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
889+
"Unexpected Finished handshake message");
890+
}
891+
884892
// Make sure that any expected CertificateVerify message
885893
// has been received and processed.
886894
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, 2017, 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

@@ -3443,8 +3447,10 @@ public void componentAdded(final ContainerEvent e) {
34433447

34443448
private void updateHtmlViews(int index, boolean inserted) {
34453449
final String title = tabPane.getTitleAt(index);
3450+
Boolean htmlDisabled = (Boolean)
3451+
tabPane.getClientProperty("html.disable");
34463452
final boolean isHTML = BasicHTML.isHTMLString(title);
3447-
if (isHTML) {
3453+
if (isHTML && !(Boolean.TRUE.equals(htmlDisabled))) {
34483454
if (htmlViews == null) { // Initialize vector
34493455
htmlViews = createHTMLVector();
34503456
} else { // Vector already exists

0 commit comments

Comments
 (0)