Skip to content

Commit 9634178

Browse files
Merge remote-tracking branch 'origin/jetty-12.0.x' into jetty-12.1.x
2 parents e3580b7 + 72f7025 commit 9634178

File tree

5 files changed

+125
-3
lines changed

5 files changed

+125
-3
lines changed

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ The following checklist is used to handle security issues:
4040
- [ ] Edit VERSION.txt and so that the CVE number is now recorded against merged PR.
4141
- [ ] Edit the release(s) on Github to identify CVE number that was addressed/resolved.
4242
- [ ] Update downstream images (Docker, etc.).
43-
- [ ] Update project website with new security entry.
43+
- [ ] Update project [website](https://jetty.org/security.html) with new security entry.
4444
- [ ] Review security processes & completion.
4545

jetty-core/jetty-http/src/main/java/org/eclipse/jetty/http/MultiPart.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ public Content.Chunk read()
817817
builder.append("\r\n");
818818

819819
// TODO: use a ByteBuffer pool and direct ByteBuffers?
820-
ByteBuffer byteBuffer = UTF_8.encode(builder.toCompleteString());
820+
ByteBuffer byteBuffer = ByteBuffer.wrap(builder.toCompleteString().getBytes(UTF_8));
821821
state = State.CONTENT;
822822
yield Content.Chunk.from(byteBuffer, false);
823823
}

jetty-core/jetty-http/src/test/java/org/eclipse/jetty/http/HttpURITest.java

+9
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,15 @@ public static Stream<String> badAuthorities()
12321232
"https://[notIpv6]/",
12331233
"https://bad[0::1::2::3::4]/",
12341234

1235+
"http://[fe80::1%25eth0]/",
1236+
"http://[fe80::1%251]/",
1237+
1238+
"http://[vulndetector.com]",
1239+
"http://hostone.com@[vulndetector.com]#hosttwo.com/",
1240+
"http://hostone.com:80@[vulndetector.com]/",
1241+
"http://[vulndetector.com]#@normal.com",
1242+
"http://hostone.com\\\\[vulndetector.com]/",
1243+
12351244
// Ambiguous empty path
12361245
"http://localhost;param",
12371246
"http://localhost:8080;param"

jetty-core/jetty-io/src/main/java/org/eclipse/jetty/io/Content.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static void write(Sink sink, boolean last, ByteBuffer byteBuffer) throws IOExcep
847847
*/
848848
static void write(Sink sink, boolean last, String utf8Content, Callback callback)
849849
{
850-
sink.write(last, StandardCharsets.UTF_8.encode(utf8Content), callback);
850+
sink.write(last, ByteBuffer.wrap(utf8Content.getBytes(StandardCharsets.UTF_8)), callback);
851851
}
852852

853853
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
//
2+
// ========================================================================
3+
// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others.
4+
//
5+
// This program and the accompanying materials are made available under the
6+
// terms of the Eclipse Public License v. 2.0 which is available at
7+
// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
8+
// which is available at https://www.apache.org/licenses/LICENSE-2.0.
9+
//
10+
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
11+
// ========================================================================
12+
//
13+
14+
package org.eclipse.jetty.io.jmh;
15+
16+
import java.nio.ByteBuffer;
17+
import java.nio.charset.StandardCharsets;
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
import java.util.concurrent.TimeUnit;
21+
22+
import org.openjdk.jmh.annotations.Benchmark;
23+
import org.openjdk.jmh.annotations.BenchmarkMode;
24+
import org.openjdk.jmh.annotations.Fork;
25+
import org.openjdk.jmh.annotations.Measurement;
26+
import org.openjdk.jmh.annotations.Mode;
27+
import org.openjdk.jmh.annotations.Param;
28+
import org.openjdk.jmh.annotations.Scope;
29+
import org.openjdk.jmh.annotations.Setup;
30+
import org.openjdk.jmh.annotations.State;
31+
import org.openjdk.jmh.annotations.Threads;
32+
import org.openjdk.jmh.annotations.Warmup;
33+
import org.openjdk.jmh.profile.GCProfiler;
34+
import org.openjdk.jmh.runner.Runner;
35+
import org.openjdk.jmh.runner.RunnerException;
36+
import org.openjdk.jmh.runner.options.Options;
37+
import org.openjdk.jmh.runner.options.OptionsBuilder;
38+
39+
@State(Scope.Benchmark)
40+
@Threads(1)
41+
@Fork(1)
42+
@Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
43+
@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
44+
public class Utf8Benchmark
45+
{
46+
// Each string is about 450 characters long.
47+
private static final Map<String, String> STRINGS_MAP = new HashMap<>()
48+
{{
49+
put("ASCII", """
50+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
51+
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
52+
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
53+
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
54+
nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
55+
qui officia deserunt mollit anim id est laborum.""");
56+
put("FR", """
57+
J'ai su là-bas que, pour quelques emplettes,
58+
Éliante est sortie, et Célimène aussi ;
59+
Mais comme l'on m'a dit que vous étiez ici,
60+
J'ai monté pour vous dire, et d'un coeur véritable,
61+
Que j'ai conçu pour vous une estime incroyable,
62+
Et que, depuis longtemps, cette estime m'a mis
63+
Dans un ardent désir d'être de vos amis.
64+
Oui, mon coeur au mérite aime à rendre justice,
65+
Et je brûle qu'un noeud d'amitié nous unisse :
66+
Je crois qu'un ami chaud, et de ma qualité""");
67+
put("JA", """
68+
参加希望の方は今すぐ登録してください。この会議では、グローバルなインタネット、Unicode、
69+
ソフトウェアの国際化およびローカリゼーション、OSおよびアプリケーションでのUnicode
70+
のインプリメンテーション、フォント、テキスト表示、マルチ言語コンピューティングにおける業界の専門家が集まります。
71+
参加希望の方は今すぐ登録してください。この会議では、グローバルなインタネット、Unicode
72+
、ソフトウェアの国際化およびローカリゼーション、OSおよびアプリケーションでのUnicode
73+
のインプリメンテーション、フォント、テキスト表示、マルチ言語コンピューティングにおける業界の専門家が集まります。
74+
参加希望の方は今すぐ登録してください。この会議では、グローバルなインタネット、Unicode
75+
、ソフトウェアの国際化およびローカリゼーション、OSおよびアプリケーションでのUnicode
76+
のインプリメンテーション、フォント、テキスト表示、マルチ言語コンピューティングにおける業界の専門家が集まります。""");
77+
}};
78+
79+
@Param({"ASCII", "FR", "JA"})
80+
String locale;
81+
82+
String utf8Content;
83+
84+
@Setup
85+
public void setUp()
86+
{
87+
utf8Content = STRINGS_MAP.get(locale);
88+
}
89+
90+
@Benchmark
91+
@BenchmarkMode({Mode.Throughput})
92+
public Object testEncode()
93+
{
94+
return StandardCharsets.UTF_8.encode(utf8Content);
95+
}
96+
97+
@Benchmark
98+
@BenchmarkMode({Mode.Throughput})
99+
public Object testWrapGetBytes()
100+
{
101+
return ByteBuffer.wrap(utf8Content.getBytes(StandardCharsets.UTF_8));
102+
}
103+
104+
public static void main(String[] args) throws RunnerException
105+
{
106+
Options opt = new OptionsBuilder()
107+
.include(Utf8Benchmark.class.getSimpleName())
108+
.addProfiler(GCProfiler.class)
109+
.build();
110+
111+
new Runner(opt).run();
112+
}
113+
}

0 commit comments

Comments
 (0)