Bug 1783290 - Uppercase CAPA response in Pop3Client.jsm to fix fetching headers only. r=mkmelin
authorPing Chen <remotenonsense@gmail.com>
Sat, 06 Aug 2022 20:24:33 +1000
changeset 36433 a1d64eb0280858575e43768e84f2a80daf84661d
parent 36432 a0226743f89a765d0b730745813649b86e56415f
child 36434 385cb359544a62c86ff8f27857dd7a54f605be96
push id20163
push user[email protected]
push dateSat, 06 Aug 2022 10:24:58 +0000
treeherdercomm-central@a1d64eb02808 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin
bugs1783290
Bug 1783290 - Uppercase CAPA response in Pop3Client.jsm to fix fetching headers only. r=mkmelin 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
@@ -460,17 +460,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) {