Bug 1579461 - Implement modern method (mutate) of removing credentials from a url in msgHdrView.js. r+a=jorgk
authoralta88@fixall.com
Fri, 06 Sep 2019 10:19:30 -0600
changeset 79095 567eed3f997df8d03dbd1b1c2935f35785734d06
parent 79094 8548767c8a99cdbaf234e6bd20fe4e9545aea1f7
child 79096 cd63b006fad7dac7c2a1698d9af5f543eaeb1278
push id9345
push userkaie@kuix.de
push dateFri, 20 Sep 2019 05:14:40 +0000
treeherdertry-comm-central@b9101c33b5e5 [default view] [failures only]
bugs1579461
Bug 1579461 - Implement modern method (mutate) of removing credentials from a url in msgHdrView.js. r+a=jorgk
mail/base/content/msgHdrView.js
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -2088,23 +2088,21 @@ AttachmentInfo.prototype = {
     let options = { method: "HEAD" };
 
     // NOTE: For internal mailbox, imap, news urls the response body must get
     // the content length with getReader().read() but we don't need to do this
     // here as libmime streams it already in addAttachmentField(). For imap or
     // news urls with credentials (username, userPass), we must remove them
     // as Request fails such urls with a MSG_URL_HAS_CREDENTIALS error.
     if (url.startsWith("imap://") || url.startsWith("news://")) {
-      let uri = makeURI(url);
-      if (uri.username) {
-        url = url.replace(uri.username + "@", "");
-      }
-      if (uri.userPass) {
-        url = url.replace(uri.userPass + "@", "");
-      }
+      url = makeURI(url)
+        .mutate()
+        .setUsername("")
+        .setUserPass("")
+        .finalize().spec;
     }
 
     let request = new Request(url, options);
 
     if (
       this.isExternalAttachment ||
       !this.sizeResolved ||
       this.ALWAYSFETCHSIZE