Bug 1783290 - Uppercase CAPA response in Pop3Client.jsm to fix fetching headers only. r=mkmelin a=wsmwk
authorPing Chen <remotenonsense@gmail.com>
Sat, 06 Aug 2022 20:24:33 +1000
changeset 47658 fe907b167d3cc356382498a2f914f44f2499e668
parent 47657 356573a42066f70fcbe805628f809f6588975869
child 47659 865680f90a34b434755cf40c43d7e1a2aed02bff
push id3770
push user[email protected]
push dateMon, 15 Aug 2022 18:50:29 +0000
treeherdercomm-beta@482914fd46f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, wsmwk
bugs1783290
Bug 1783290 - Uppercase CAPA response in Pop3Client.jsm to fix fetching headers only. r=mkmelin a=wsmwk Differential Revision: https://phabricator.services.mozilla.com/D153884
mailnews/local/src/Pop3Client.jsm
mailnews/local/test/unit/test_pop3Client.js
mailnews/test/fakeserver/Pop3d.jsm
--- a/mailnews/local/src/Pop3Client.jsm
+++ b/mailnews/local/src/Pop3Client.jsm
@@ -459,17 +459,17 @@ class Pop3Client {
   _actionCapaResponse = res => {
     if (res.status && !res.success) {
       this._actionChooseFirstAuthMethod();
       return;
     }
     this._lineReader.read(
       res.data,
       line => {
-        line = line.trim();
+        line = line.trim().toUpperCase();
         if (line == "USER") {
           this._supportedAuthMethods.push("USERPASS");
         } else if (line.startsWith("SASL ")) {
           this._supportedAuthMethods.push(...line.slice(5).split(" "));
         } else {
           this._capabilities.push(line.split(" ")[0]);
         }
       },
--- a/mailnews/local/test/unit/test_pop3Client.js
+++ b/mailnews/local/test/unit/test_pop3Client.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-let [daemon, server] = setupServerDaemon();
+let [daemon, server, handler] = setupServerDaemon();
+handler.kCapabilities = ["uidl", "top"]; // CAPA response is case-insensitive.
 server.start();
 registerCleanupFunction(() => {
   server.stop();
 });
 
 /**
  * Test when alwaysSTARTTLS is set, but the server doesn't support STARTTLS,
  * should abort after CAPA response.
--- a/mailnews/test/fakeserver/Pop3d.jsm
+++ b/mailnews/test/fakeserver/Pop3d.jsm
@@ -190,17 +190,16 @@ POP3_RFC1939_handler.prototype = {
       result += i + 1 + " " + this._daemon._messages[i].uidl + "\r\n";
     }
 
     result += ".";
     return result;
   },
   TOP(args) {
     let [messageNumber, numberOfBodyLines] = args.split(" ");
-    console.log({ args });
     if (this._state != kStateTransaction) {
       return "-ERR invalid state";
     }
     let result = "+OK\r\n";
     let msg = this._daemon._messages[messageNumber - 1].fileData;
     let index = msg.indexOf("\r\n\r\n");
     result += msg.slice(0, index);
     if (numberOfBodyLines) {