elharo commented on code in PR #109:
URL: https://github.com/apache/maven-shared-io/pull/109#discussion_r3695495388


##########
src/main/java/org/apache/maven/shared/io/download/DefaultDownloadManager.java:
##########
@@ -115,8 +115,13 @@ public File download(String url, List<TransferListener> 
transferListeners, Messa
         messageHolder.addMessage("Download target is: " + 
downloaded.getAbsolutePath());
 
         // split the download URL into base URL and remote path for 
connecting, then retrieving.
+        // Build baseUrl from URL components to avoid corruption by query 
strings or fragments.
         String remotePath = sourceUrl.getPath();
-        String baseUrl = url.substring(0, url.length() - remotePath.length());
+        int port = sourceUrl.getPort();
+        String baseUrl = sourceUrl.getProtocol() + "://"

Review Comment:
   Been a minute since I looked into the official URI specs but I'm not sure 
this is a complete URL reconstruction. The authority can have  a password 
component, and not all absolute URIs (URLs?) have ://. Some just have :. This 
is tricky. Might be OK here. I'm just not sure.



-- 
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]

Reply via email to