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


##########
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:
   Hey @elharo , I've committed the changes.
   
   **getAuthority()** returns the authority verbatim, so user:secret@host:8080 
stays intact - wagon's Repository parses the credentials back out itself. Added 
a test covering username, password and port.
     
    On the :- java.net.URL won't construct without a scheme, so protocol + ":" 
is always correct. Only the // varies, hence the conditional authority.
    
   **Also added a guard:** an empty authority on a non-file protocol now throws 
DownloadFailedException instead of an obscure StringIndexOutOfBoundsException 
from wagon's parser. file: is exempt since authority-less file URLs are normal.



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