Skip to content

Commit ba2bd83

Browse files
committed
Merge
2 parents 94f8a74 + 162dbac commit ba2bd83

File tree

18 files changed

+279
-84
lines changed

18 files changed

+279
-84
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, 2021, 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, 2021, 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
@@ -42,6 +42,8 @@
4242
import sun.net.www.protocol.http.AuthenticatorKeys;
4343
import sun.net.www.protocol.http.HttpURLConnection;
4444
import sun.util.logging.PlatformLogger;
45+
46+
import static sun.net.util.ProxyUtil.copyProxy;
4547
import static sun.net.www.protocol.http.HttpURLConnection.TunnelState.*;
4648
import sun.security.action.GetPropertyAction;
4749

@@ -268,7 +270,7 @@ public HttpClient(URL url, String proxyHost, int proxyPort)
268270
}
269271

270272
protected HttpClient(URL url, Proxy p, int to) throws IOException {
271-
proxy = (p == null) ? Proxy.NO_PROXY : p;
273+
proxy = p == null ? Proxy.NO_PROXY : copyProxy(p);
272274
this.host = url.getHost();
273275
this.url = url;
274276
port = url.getPort();
@@ -333,9 +335,7 @@ public static HttpClient New(URL url, boolean useCache)
333335
public static HttpClient New(URL url, Proxy p, int to, boolean useCache,
334336
HttpURLConnection httpuc) throws IOException
335337
{
336-
if (p == null) {
337-
p = Proxy.NO_PROXY;
338-
}
338+
p = p == null ? Proxy.NO_PROXY : copyProxy(p);
339339
HttpClient ret = null;
340340
/* see if one's already around */
341341
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, 2021, 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
@@ -49,6 +49,7 @@
4949
import java.util.Iterator;
5050
import java.security.Permission;
5151
import java.util.Properties;
52+
5253
import sun.net.NetworkClient;
5354
import sun.net.util.IPAddressUtil;
5455
import sun.net.www.MessageHeader;
@@ -62,6 +63,7 @@
6263
import sun.net.www.ParseUtil;
6364
import sun.security.action.GetPropertyAction;
6465

66+
import static sun.net.util.ProxyUtil.copyProxy;
6567

6668
/**
6769
* This class Opens an FTP input (or output) stream given a URL.
@@ -252,7 +254,7 @@ public ProxySelector run() {
252254
}
253255
final Iterator<Proxy> it = proxies.iterator();
254256
while (it.hasNext()) {
255-
p = it.next();
257+
p = copyProxy(it.next());
256258
if (p == null || p == Proxy.NO_PROXY ||
257259
p.type() == Proxy.Type.SOCKS) {
258260
break;

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

Lines changed: 5 additions & 7 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
@@ -32,11 +32,9 @@
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;
3735
import java.util.Objects;
38-
import sun.net.ftp.FtpClient;
39-
import sun.net.www.protocol.http.HttpURLConnection;
36+
37+
import static sun.net.util.ProxyUtil.copyProxy;
4038

4139
/** open an ftp connection given a URL */
4240
public class Handler extends java.net.URLStreamHandler {
@@ -56,8 +54,8 @@ protected java.net.URLConnection openConnection(URL u)
5654
return openConnection(u, null);
5755
}
5856

59-
protected java.net.URLConnection openConnection(URL u, Proxy p)
57+
protected java.net.URLConnection openConnection(URL u, Proxy proxy)
6058
throws IOException {
61-
return new FtpURLConnection(u, p);
59+
return new FtpURLConnection(u, copyProxy(proxy));
6260
}
6361
}

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, 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
@@ -83,6 +83,7 @@
8383
import java.util.Properties;
8484
import java.util.concurrent.locks.ReentrantLock;
8585

86+
import static sun.net.util.ProxyUtil.copyProxy;
8687
import static sun.net.www.protocol.http.AuthScheme.BASIC;
8788
import static sun.net.www.protocol.http.AuthScheme.DIGEST;
8889
import static sun.net.www.protocol.http.AuthScheme.NTLM;
@@ -940,7 +941,7 @@ protected HttpURLConnection(URL u, Proxy p, Handler handler)
940941
responses = new MessageHeader(maxHeaderSize);
941942
userHeaders = new MessageHeader();
942943
this.handler = handler;
943-
instProxy = p;
944+
instProxy = copyProxy(p);
944945
if (instProxy instanceof sun.net.ApplicationProxy) {
945946
/* Application set Proxies should not have access to cookies
946947
* in a secure environment unless explicitly allowed. */
@@ -1255,7 +1256,7 @@ public ProxySelector run() {
12551256
final Iterator<Proxy> it = proxies.iterator();
12561257
Proxy p;
12571258
while (it.hasNext()) {
1258-
p = it.next();
1259+
p = copyProxy(it.next());
12591260
try {
12601261
if (!failedOnce) {
12611262
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, 2021, 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
@@ -1160,6 +1160,15 @@ public void consume(ConnectionContext context,
11601160

11611161
// clean up this consumer
11621162
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE.id);
1163+
1164+
// Ensure that the Certificate message has not been sent w/o
1165+
// an EncryptedExtensions preceding
1166+
if (hc.handshakeConsumers.containsKey(
1167+
SSLHandshake.ENCRYPTED_EXTENSIONS.id)) {
1168+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1169+
"Unexpected Certificate handshake message");
1170+
}
1171+
11631172
T13CertificateMessage cm = new T13CertificateMessage(hc, message);
11641173
if (hc.sslConfig.isClientMode) {
11651174
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, 2021, 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
@@ -1160,6 +1160,14 @@ public void consume(ConnectionContext context,
11601160
// Clean up this consumer
11611161
hc.handshakeConsumers.remove(SSLHandshake.CERTIFICATE_VERIFY.id);
11621162

1163+
// Ensure that the Certificate Verify message has not been sent w/o
1164+
// a Certificate message preceding
1165+
if (hc.handshakeConsumers.containsKey(
1166+
SSLHandshake.CERTIFICATE.id)) {
1167+
throw hc.conContext.fatal(Alert.UNEXPECTED_MESSAGE,
1168+
"Unexpected Certificate Verify handshake message");
1169+
}
1170+
11631171
T13CertificateVerifyMessage cvm =
11641172
new T13CertificateVerifyMessage(hc, message);
11651173
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, 2021, 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, 2021, 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

@@ -3446,8 +3450,10 @@ public void componentAdded(final ContainerEvent e) {
34463450

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

0 commit comments

Comments
 (0)