Skip to content

Commit 6675240

Browse files
authored
make QueryStringDecode Public (#11671)
This commits makes QueryStringDecode Public to avoid duplicating it in other modules. For example: https://github.com/micronaut-projects/micronaut-servlet/blob/5.2.x/http-poja-common/src/main/java/io/micronaut/http/poja/util/QueryStringDecoder.java It also sets: * org.gradle.jvmargs=-Xmx4g To try to avoid out of memory errors with sonar static analysis
1 parent 1004595 commit 6675240

File tree

3 files changed

+476
-16
lines changed

3 files changed

+476
-16
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ graalVersion=21.0.5
5050

5151
org.gradle.caching=true
5252
org.gradle.parallel=true
53-
org.gradle.jvmargs=-Xmx1g
53+
org.gradle.jvmargs=-Xmx4g
5454
systemProp.predictiveTestSelection=false
5555
predictiveTestSelection=false
5656

http/src/main/java/io/micronaut/http/uri/QueryStringDecoder.java

+20-15
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,36 @@
3232
* Splits an HTTP query string into a path string and key-value parameter pairs.
3333
* This decoder is for one time use only. Create a new instance for each URI:
3434
* <pre>
35-
* {@link QueryStringDecoder} decoder = new {@link QueryStringDecoder}("/hello?recipient=world&x=1;y=2");
35+
* {@code
36+
* QueryStringDecoder decoder = new QueryStringDecoder("/hello?recipient=world&x=1;y=2");
3637
* assert decoder.path().equals("/hello");
3738
* assert decoder.parameters().get("recipient").get(0).equals("world");
3839
* assert decoder.parameters().get("x").get(0).equals("1");
3940
* assert decoder.parameters().get("y").get(0).equals("2");
41+
* }
4042
* </pre>
4143
*
4244
* This decoder can also decode the content of an HTTP POST request whose
4345
* content type is {@code application/x-www-form-urlencoded}:
4446
* <pre>
45-
* {@link QueryStringDecoder} decoder = new {@link QueryStringDecoder}("recipient=world&x=1;y=2", false);
47+
* {@code
48+
* QueryStringDecoder decoder = new QueryStringDecoder("recipient=world&x=1;y=2", false);
4649
* ...
50+
* }
4751
* </pre>
4852
*
49-
* <h3>HashDOS vulnerability fix</h3>
53+
* HashDOS vulnerability fix
5054
*
5155
* As a workaround to the <a href="https://netty.io/s/hashdos">HashDOS</a> vulnerability, the decoder
5256
* limits the maximum number of decoded key-value parameter pairs, up to {@literal 1024} by
5357
* default, and you can configure it when you construct the decoder by passing an additional
5458
* integer parameter.
55-
* <p>
59+
*
5660
* Note: Forked from Netty core.
61+
* This class is used internally by other Micronaut Modules. Don't reduce visibility.
5762
*/
5863
@Internal
59-
final class QueryStringDecoder {
64+
public final class QueryStringDecoder {
6065

6166
private static final int DEFAULT_MAX_PARAMS = 1024;
6267

@@ -74,7 +79,7 @@ final class QueryStringDecoder {
7479
*
7580
* @param uri The URI
7681
*/
77-
QueryStringDecoder(String uri) {
82+
public QueryStringDecoder(String uri) {
7883
this(uri, StandardCharsets.UTF_8);
7984
}
8085

@@ -85,7 +90,7 @@ final class QueryStringDecoder {
8590
* @param uri The URI
8691
* @param hasPath whether a path is present
8792
*/
88-
QueryStringDecoder(String uri, boolean hasPath) {
93+
public QueryStringDecoder(String uri, boolean hasPath) {
8994
this(uri, StandardCharsets.UTF_8, hasPath);
9095
}
9196

@@ -96,7 +101,7 @@ final class QueryStringDecoder {
96101
* @param uri The URI
97102
* @param charset The charset to use
98103
*/
99-
QueryStringDecoder(String uri, Charset charset) {
104+
public QueryStringDecoder(String uri, Charset charset) {
100105
this(uri, charset, true);
101106
}
102107

@@ -108,7 +113,7 @@ final class QueryStringDecoder {
108113
* @param charset The charset to use
109114
* @param hasPath whether a path is present
110115
*/
111-
QueryStringDecoder(String uri, Charset charset, boolean hasPath) {
116+
public QueryStringDecoder(String uri, Charset charset, boolean hasPath) {
112117
this(uri, charset, hasPath, DEFAULT_MAX_PARAMS);
113118
}
114119

@@ -121,11 +126,11 @@ final class QueryStringDecoder {
121126
* @param hasPath whether a path is present
122127
* @param maxParams The maximum number of params
123128
*/
124-
QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams) {
129+
public QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams) {
125130
this(uri, charset, hasPath, maxParams, false);
126131
}
127132

128-
QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams, boolean semicolonIsNormalChar) {
133+
public QueryStringDecoder(String uri, Charset charset, boolean hasPath, int maxParams, boolean semicolonIsNormalChar) {
129134
this.uri = Objects.requireNonNull(uri, "uri");
130135
this.charset = Objects.requireNonNull(charset, "charset");
131136
this.maxParams = maxParams;
@@ -141,7 +146,7 @@ final class QueryStringDecoder {
141146
*
142147
* @param uri The URI
143148
*/
144-
QueryStringDecoder(URI uri) {
149+
public QueryStringDecoder(URI uri) {
145150
this(uri, StandardCharsets.UTF_8);
146151
}
147152

@@ -152,7 +157,7 @@ final class QueryStringDecoder {
152157
* @param uri The URI
153158
* @param charset The charset to use
154159
*/
155-
QueryStringDecoder(URI uri, Charset charset) {
160+
public QueryStringDecoder(URI uri, Charset charset) {
156161
this(uri, charset, DEFAULT_MAX_PARAMS);
157162
}
158163

@@ -164,11 +169,11 @@ final class QueryStringDecoder {
164169
* @param charset The charset to use
165170
* @param maxParams The maximum number of params
166171
*/
167-
QueryStringDecoder(URI uri, Charset charset, int maxParams) {
172+
public QueryStringDecoder(URI uri, Charset charset, int maxParams) {
168173
this(uri, charset, maxParams, false);
169174
}
170175

171-
QueryStringDecoder(URI uri, Charset charset, int maxParams, boolean semicolonIsNormalChar) {
176+
public QueryStringDecoder(URI uri, Charset charset, int maxParams, boolean semicolonIsNormalChar) {
172177
String rawPath = uri.getRawPath();
173178
if (rawPath == null) {
174179
rawPath = EMPTY_STRING;

0 commit comments

Comments
 (0)