32
32
* Splits an HTTP query string into a path string and key-value parameter pairs.
33
33
* This decoder is for one time use only. Create a new instance for each URI:
34
34
* <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");
36
37
* assert decoder.path().equals("/hello");
37
38
* assert decoder.parameters().get("recipient").get(0).equals("world");
38
39
* assert decoder.parameters().get("x").get(0).equals("1");
39
40
* assert decoder.parameters().get("y").get(0).equals("2");
41
+ * }
40
42
* </pre>
41
43
*
42
44
* This decoder can also decode the content of an HTTP POST request whose
43
45
* content type is {@code application/x-www-form-urlencoded}:
44
46
* <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);
46
49
* ...
50
+ * }
47
51
* </pre>
48
52
*
49
- * <h3> HashDOS vulnerability fix</h3>
53
+ * HashDOS vulnerability fix
50
54
*
51
55
* As a workaround to the <a href="https://netty.io/s/hashdos">HashDOS</a> vulnerability, the decoder
52
56
* limits the maximum number of decoded key-value parameter pairs, up to {@literal 1024} by
53
57
* default, and you can configure it when you construct the decoder by passing an additional
54
58
* integer parameter.
55
- * <p>
59
+ *
56
60
* Note: Forked from Netty core.
61
+ * This class is used internally by other Micronaut Modules. Don't reduce visibility.
57
62
*/
58
63
@ Internal
59
- final class QueryStringDecoder {
64
+ public final class QueryStringDecoder {
60
65
61
66
private static final int DEFAULT_MAX_PARAMS = 1024 ;
62
67
@@ -74,7 +79,7 @@ final class QueryStringDecoder {
74
79
*
75
80
* @param uri The URI
76
81
*/
77
- QueryStringDecoder (String uri ) {
82
+ public QueryStringDecoder (String uri ) {
78
83
this (uri , StandardCharsets .UTF_8 );
79
84
}
80
85
@@ -85,7 +90,7 @@ final class QueryStringDecoder {
85
90
* @param uri The URI
86
91
* @param hasPath whether a path is present
87
92
*/
88
- QueryStringDecoder (String uri , boolean hasPath ) {
93
+ public QueryStringDecoder (String uri , boolean hasPath ) {
89
94
this (uri , StandardCharsets .UTF_8 , hasPath );
90
95
}
91
96
@@ -96,7 +101,7 @@ final class QueryStringDecoder {
96
101
* @param uri The URI
97
102
* @param charset The charset to use
98
103
*/
99
- QueryStringDecoder (String uri , Charset charset ) {
104
+ public QueryStringDecoder (String uri , Charset charset ) {
100
105
this (uri , charset , true );
101
106
}
102
107
@@ -108,7 +113,7 @@ final class QueryStringDecoder {
108
113
* @param charset The charset to use
109
114
* @param hasPath whether a path is present
110
115
*/
111
- QueryStringDecoder (String uri , Charset charset , boolean hasPath ) {
116
+ public QueryStringDecoder (String uri , Charset charset , boolean hasPath ) {
112
117
this (uri , charset , hasPath , DEFAULT_MAX_PARAMS );
113
118
}
114
119
@@ -121,11 +126,11 @@ final class QueryStringDecoder {
121
126
* @param hasPath whether a path is present
122
127
* @param maxParams The maximum number of params
123
128
*/
124
- QueryStringDecoder (String uri , Charset charset , boolean hasPath , int maxParams ) {
129
+ public QueryStringDecoder (String uri , Charset charset , boolean hasPath , int maxParams ) {
125
130
this (uri , charset , hasPath , maxParams , false );
126
131
}
127
132
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 ) {
129
134
this .uri = Objects .requireNonNull (uri , "uri" );
130
135
this .charset = Objects .requireNonNull (charset , "charset" );
131
136
this .maxParams = maxParams ;
@@ -141,7 +146,7 @@ final class QueryStringDecoder {
141
146
*
142
147
* @param uri The URI
143
148
*/
144
- QueryStringDecoder (URI uri ) {
149
+ public QueryStringDecoder (URI uri ) {
145
150
this (uri , StandardCharsets .UTF_8 );
146
151
}
147
152
@@ -152,7 +157,7 @@ final class QueryStringDecoder {
152
157
* @param uri The URI
153
158
* @param charset The charset to use
154
159
*/
155
- QueryStringDecoder (URI uri , Charset charset ) {
160
+ public QueryStringDecoder (URI uri , Charset charset ) {
156
161
this (uri , charset , DEFAULT_MAX_PARAMS );
157
162
}
158
163
@@ -164,11 +169,11 @@ final class QueryStringDecoder {
164
169
* @param charset The charset to use
165
170
* @param maxParams The maximum number of params
166
171
*/
167
- QueryStringDecoder (URI uri , Charset charset , int maxParams ) {
172
+ public QueryStringDecoder (URI uri , Charset charset , int maxParams ) {
168
173
this (uri , charset , maxParams , false );
169
174
}
170
175
171
- QueryStringDecoder (URI uri , Charset charset , int maxParams , boolean semicolonIsNormalChar ) {
176
+ public QueryStringDecoder (URI uri , Charset charset , int maxParams , boolean semicolonIsNormalChar ) {
172
177
String rawPath = uri .getRawPath ();
173
178
if (rawPath == null ) {
174
179
rawPath = EMPTY_STRING ;
0 commit comments