@bobfrankston/iflow 1.0.47 → 1.0.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/imaplib/imap-native.js +24 -2
- package/imaplib/imap-protocol.js +4 -3
- package/package.json +1 -1
package/imaplib/imap-native.js
CHANGED
|
@@ -215,13 +215,30 @@ export class NativeImapClient {
|
|
|
215
215
|
const tag = proto.nextTag();
|
|
216
216
|
const responses = await this.sendCommand(tag, proto.listCommand(tag));
|
|
217
217
|
const folders = [];
|
|
218
|
+
let unparsed = 0;
|
|
219
|
+
const listResponses = responses.filter(r => r.tag === "*" && r.type === "LIST");
|
|
220
|
+
if (listResponses.length === 0 && responses.length > 0) {
|
|
221
|
+
console.error(` [imap] LIST returned ${responses.length} responses but none were LIST type. Types: ${responses.map(r => `${r.tag}:${r.type}`).join(", ")}`);
|
|
222
|
+
if (responses.length <= 5) {
|
|
223
|
+
for (const r of responses)
|
|
224
|
+
console.error(` [imap] raw: ${JSON.stringify(r.text.substring(0, 200))}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
218
227
|
for (const r of responses) {
|
|
219
228
|
if (r.tag === "*" && r.type === "LIST") {
|
|
220
229
|
const parsed = proto.parseListResponse(r.text);
|
|
221
|
-
if (parsed)
|
|
230
|
+
if (parsed) {
|
|
222
231
|
folders.push(parsed);
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
unparsed++;
|
|
235
|
+
if (unparsed <= 3)
|
|
236
|
+
console.error(` [imap] Unparsed LIST response: ${JSON.stringify(r.text.substring(0, 200))}`);
|
|
237
|
+
}
|
|
223
238
|
}
|
|
224
239
|
}
|
|
240
|
+
if (unparsed > 0)
|
|
241
|
+
console.error(` [imap] ${unparsed} LIST responses could not be parsed (${responses.length} total responses)`);
|
|
225
242
|
return folders;
|
|
226
243
|
}
|
|
227
244
|
async getStatus(mailbox) {
|
|
@@ -468,8 +485,13 @@ export class NativeImapClient {
|
|
|
468
485
|
// Check for literal {size}\r\n — reading exact byte count of literal data
|
|
469
486
|
if (this.pendingCommand?.literalBytes != null) {
|
|
470
487
|
if (this.buffer.length >= this.pendingCommand.literalBytes) {
|
|
471
|
-
|
|
488
|
+
let literal = this.buffer.substring(0, this.pendingCommand.literalBytes);
|
|
472
489
|
this.buffer = this.buffer.substring(this.pendingCommand.literalBytes);
|
|
490
|
+
// For non-BODY literals (e.g. display names in ENVELOPE), wrap in quotes
|
|
491
|
+
// so tokenizeParenList treats them as a single token
|
|
492
|
+
if (!this.pendingCommand.currentLiteralKey) {
|
|
493
|
+
literal = `"${literal.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\r?\n/g, "")}"`;
|
|
494
|
+
}
|
|
473
495
|
this.pendingCommand.literalBuffer = (this.pendingCommand.literalBuffer || "") + literal;
|
|
474
496
|
this.pendingCommand.literalBytes = undefined;
|
|
475
497
|
// Store the literal data by its BODY key for parseFetchResponses
|
package/imaplib/imap-protocol.js
CHANGED
|
@@ -143,13 +143,14 @@ export function parseResponseLine(line) {
|
|
|
143
143
|
}
|
|
144
144
|
/** Parse a LIST response line: * LIST (\flags) "delimiter" "path" */
|
|
145
145
|
export function parseListResponse(text) {
|
|
146
|
-
// Match:
|
|
147
|
-
|
|
146
|
+
// Match: (flags) "delimiter" "path" or (flags) "delimiter" path
|
|
147
|
+
// The "LIST" prefix may or may not be present (parseResponseLine may strip it into r.type)
|
|
148
|
+
const match = text.match(/^(?:LIST\s+)?\(([^)]*)\)\s+"([^"]*)"\s+(?:"([^"]+)"|(\S+))/i);
|
|
148
149
|
if (!match)
|
|
149
150
|
return null;
|
|
150
151
|
const flags = match[1] ? match[1].split(/\s+/).filter(Boolean) : [];
|
|
151
152
|
const delimiter = match[2] || ".";
|
|
152
|
-
const path = match[3] || match[4] || "";
|
|
153
|
+
const path = (match[3] || match[4] || "").replace(/\r?\n$/, "");
|
|
153
154
|
return { flags, delimiter, path };
|
|
154
155
|
}
|
|
155
156
|
/** Parse STATUS response: * STATUS "mailbox" (MESSAGES n UIDNEXT n ...) */
|