ok2c commented on code in PR #517:
URL: 
https://github.com/apache/httpcomponents-core/pull/517#discussion_r1995335981


##########
httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java:
##########
@@ -391,14 +438,16 @@ private String buildString() {
                 formatQuery(sb, this.queryParams, this.charset, false);
             } else if (this.query != null) {
                 sb.append("?");
-                PercentCodec.encode(sb, this.query, this.charset, 
PercentCodec.URIC, false);
+                PercentCodec.encode(sb, this.query, this.charset,
+                        encodingPolicy == EncodingPolicy.ALL_RESERVED ? 
PercentCodec.UNRESERVED : PercentCodec.FRAGMENT, false);

Review Comment:
   @arturobernalg Careful there. Here we are encoding a complete query that may 
use sub-delims. Even in `ALL_RESERVED` mode it should still be `URIC`.
   
   I suppose this line should be 
   ```
   encodingPolicy == EncodingPolicy.ALL_RESERVED ? PercentCodec.URIC : 
PercentCodec.QUERY, false)
   ```



##########
httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java:
##########
@@ -356,18 +399,22 @@ private String buildString() {
                 } else if (this.userInfo != null) {
                     final int idx = this.userInfo.indexOf(':');
                     if (idx != -1) {
-                        PercentCodec.encode(sb, this.userInfo.substring(0, 
idx), this.charset);
+                        PercentCodec.encode(sb, this.userInfo.substring(0, 
idx), this.charset,
+                                encodingPolicy == EncodingPolicy.ALL_RESERVED 
? PercentCodec.UNRESERVED : PercentCodec.URIC, false);
                         sb.append(':');
-                        PercentCodec.encode(sb, this.userInfo.substring(idx + 
1), this.charset);
+                        PercentCodec.encode(sb, this.userInfo.substring(idx + 
1), this.charset,
+                                encodingPolicy == EncodingPolicy.ALL_RESERVED 
? PercentCodec.UNRESERVED : PercentCodec.URIC, false);
                     } else {
-                        PercentCodec.encode(sb, this.userInfo, this.charset);
+                        PercentCodec.encode(sb, this.userInfo, this.charset,
+                                encodingPolicy == EncodingPolicy.ALL_RESERVED 
? PercentCodec.UNRESERVED : PercentCodec.URIC, false);
                     }
                     sb.append("@");
                 }
                 if (InetAddressUtils.isIPv6(this.host)) {
                     sb.append("[").append(this.host).append("]");
                 } else {
-                    sb.append(PercentCodec.encode(this.host, this.charset));
+                    PercentCodec.encode(sb, this.host, this.charset,
+                            encodingPolicy == EncodingPolicy.ALL_RESERVED ? 
PercentCodec.UNRESERVED : PercentCodec.URIC, false);

Review Comment:
   @arturobernalg Should not it be `REG_NAME`, not `URIC`?



##########
httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java:
##########
@@ -356,18 +399,22 @@ private String buildString() {
                 } else if (this.userInfo != null) {
                     final int idx = this.userInfo.indexOf(':');
                     if (idx != -1) {
-                        PercentCodec.encode(sb, this.userInfo.substring(0, 
idx), this.charset);
+                        PercentCodec.encode(sb, this.userInfo.substring(0, 
idx), this.charset,
+                                encodingPolicy == EncodingPolicy.ALL_RESERVED 
? PercentCodec.UNRESERVED : PercentCodec.URIC, false);

Review Comment:
   @arturobernalg Should not it be `USERINFO`, not `URIC`? Same below.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org
For additional commands, e-mail: dev-h...@hc.apache.org

Reply via email to