jira-importer opened a new issue, #1284:
URL: https://github.com/apache/httpcomponents-core/issues/1284

   **[Carter 
Kozak](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ckozak)** 
opened 
**[HTTPCORE-671](https://issues.apache.org/jira/browse/HTTPCORE-671?redirect=false)**
 and commented
   
   ```java
   new URIBuilder("https://[::1]:432/path";).build();
   Correctly produces 'https://[::1]:432/path'
   ```
   
   ```java
   new URIBuilder("https://[::1]:432/path";).setPort(123).build();
   Incorrectly produces 'https://%5B%3A%3A1%5D:123/path'
   where the resulting uri.getPort is -1 and uri.getHost() is null.
   ```
   
   The second example fails because we skip the fast path that preserves input 
data when mutations are made.
   
   I think we need to check for the existence of 
https://tools.ietf.org/html/rfc2732 brackets in a third branch: 
https://github.com/apache/httpcomponents-core/blob/cfb6871bd84e0f17068dea1c17d05b848c02ea69/httpcore5/src/main/java/org/apache/hc/core5/net/URIBuilder.java#L293-L297
   
    
   
   Alternatively we could strip brackets when we decode/store the host value in 
URIBuilder, however the 'getHost' result might be confusing.
   
   
   ---
   
   **Affects:** 5.1
   
   **Backported to:** 
[5.1.1](https://github.com/apache/httpcomponents-core/milestone/73?closed=1)
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to