New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-imap

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-imap - npm Package Compare versions

Comparing version 0.9.0 to 0.9.1

16

lib/Connection.js

@@ -0,1 +1,3 @@

'use strict';
const tls = require('tls'),

@@ -1025,2 +1027,13 @@ crypto = require('crypto'),

else if (type === 'bad' || type === 'no') {
if (info.textCode
&& info.textCode.Key
&& info.textCode.Key === 'WEBALERT'
) {
this.emit('webalert', {
url: textCode.val,
message: info.text
});
}
if (this.state === 'connected' && !this._curReq) {

@@ -1034,2 +1047,5 @@ clearTimeout(this._tmrConn);

}
}

@@ -1036,0 +1052,0 @@ else if (type === 'exists') {

135

lib/Parser.js

@@ -0,1 +1,3 @@

'use strict';
const EventEmitter = require('events').EventEmitter,

@@ -46,3 +48,3 @@ ReadableStream = require('stream').Readable

this.debug = debug;
var self = this;
const self = this;
this._cbReadable = function () {

@@ -75,3 +77,3 @@ if (self._ignoreReadable)

if (this._stream.readable) {
var r = this._stream.read(n);
const r = this._stream.read(n);
r && this._parse(r);

@@ -81,8 +83,11 @@ }

_parse(data) {
var i = 0, datalen = data.length, idxlf;
let i = 0;
let idxlf;
const datalen = data.length;
if (this._literallen > 0) {
if (this._body) {
var body = this._body;
const body = this._body;
if (datalen >= this._literallen) {
var litlen = this._literallen;
const litlen = this._literallen;
i = litlen;

@@ -100,3 +105,3 @@ this._literallen = 0;

this._literallen -= datalen;
var r = body.push(data);
const r = body.push(data);
if (!r) {

@@ -130,3 +135,3 @@ body._read = this._cbReadable;

if (RE_PRECEDING.test(this._buffer)) {
var firstChar = this._buffer[0];
const firstChar = this._buffer[0];
if (firstChar === '*')

@@ -160,3 +165,3 @@ this._resUntagged();

_resTagged() {
var m;
let m;
if (m = RE_LITERAL.exec(this._buffer)) {

@@ -181,6 +186,8 @@ // non-BODY literal -- buffer it

_resUntagged() {
var m;
// console.log('_resUntagged')
let m;
if (m = RE_BODYLITERAL.exec(this._buffer)) {
// console.log('RE_BODYLITERAL', this._buffer);
// BODY literal -- stream it
var which = m[1], size = parseInt(m[2], 10);
const which = m[1], size = parseInt(m[2], 10);
this._literallen = size;

@@ -199,2 +206,3 @@ this._body = new ReadableStream();

else if (m = RE_LITERAL.exec(this._buffer)) {
// console.log('RE_LITERAL', this._buffer);
// non-BODY literal -- buffer it

@@ -205,2 +213,3 @@ this._buffer = this._buffer.replace(RE_LITERAL, LITPLACEHOLDER);

else if (m = RE_UNTAGGED.exec(this._buffer)) {
// console.log('RE_UNTAGGED', this._buffer);
this._buffer = '';

@@ -212,3 +221,3 @@ // normal single line response

// m[5] = response text (optional)
var type, num, textCode, val;
let type, num, textCode, val;
if (m[2] !== undefined)

@@ -219,2 +228,3 @@ num = parseInt(m[2], 10);

type = (m[1] || m[3]).toLowerCase();
// console.log('Untagged Type: ', type);
if (type === 'flags'

@@ -227,3 +237,3 @@ || type === 'search'

// CONDSTORE search response
var p = RE_SEARCH_MODSEQ.exec(m[5]);
const p = RE_SEARCH_MODSEQ.exec(m[5]);
val = {

@@ -247,2 +257,3 @@ results: p[1].split(' '),

else if (type === 'thread') {
if (m[5])

@@ -269,3 +280,5 @@ val = parseExpr(m[5], this._literals);

val = parseQuotaRoot(m[5], this._literals);
else
else if (type === 'no') {
val = m[5]
} else
val = m[5];

@@ -284,3 +297,4 @@ this._literals = [];

_resContinue() {
var m = RE_CONTINUE.exec(this._buffer), textCode, text;
const m = RE_CONTINUE.exec(this._buffer);
let textCode, text;
this._buffer = '';

@@ -307,3 +321,3 @@ if (!m)

function indexOfCh(buffer, len, i, ch) {
var r = -1;
let r = -1;
for (; i < len; ++i) {

@@ -319,3 +333,3 @@ if (buffer[i] === ch) {

function parseTextCode(text, literals) {
var r = parseExpr(text, literals);
const r = parseExpr(text, literals);
if (r.length === 1)

@@ -328,3 +342,3 @@ return r[0];

function parseESearch(text, literals) {
var r = parseExpr(text.toUpperCase().replace('UID', ''), literals),
const r = parseExpr(text.toUpperCase().replace('UID', ''), literals),
attrs = {};

@@ -336,3 +350,3 @@

for (var i = 1, len = r.length, key, val; i < len; i += 2) {
for (let i = 1, len = r.length, key, val; i < len; i += 2) {
key = r[i].toLowerCase();

@@ -349,7 +363,7 @@ val = r[i + 1];

function parseId(text, literals) {
var r = parseExpr(text, literals),
const r = parseExpr(text, literals),
id = {};
if (r[0] === null)
return null;
for (var i = 0, len = r[0].length; i < len; i += 2)
for (let i = 0, len = r[0].length; i < len; i += 2)
id[r[0][i].toLowerCase()] = r[0][i + 1];

@@ -361,6 +375,6 @@

function parseQuota(text, literals) {
var r = parseExpr(text, literals),
const r = parseExpr(text, literals),
resources = {};
for (var i = 0, len = r[1].length; i < len; i += 3) {
for (let i = 0, len = r[1].length; i < len; i += 3) {
resources[r[1][i].toLowerCase()] = {

@@ -379,3 +393,3 @@ usage: r[1][i + 1],

function parseQuotaRoot(text, literals) {
var r = parseExpr(text, literals);
const r = parseExpr(text, literals);

@@ -389,3 +403,3 @@ return {

function parseBoxList(text, literals) {
var r = parseExpr(text, literals);
const r = parseExpr(text, literals);
return {

@@ -399,3 +413,4 @@ flags: r[0],

function parseNamespaces(text, literals) {
var r = parseExpr(text, literals), i, len, j, len2, ns, nsobj, namespaces, n;
const r = parseExpr(text, literals);
let i, len, j, len2, ns, nsobj, namespaces, n;

@@ -430,5 +445,5 @@ for (n = 0; n < 3; ++n) {

function parseStatus(text, literals) {
var r = parseExpr(text, literals), attrs = {};
const r = parseExpr(text, literals), attrs = {};
// r[1] is [KEY1, VAL1, KEY2, VAL2, .... KEYn, VALn]
for (var i = 0, len = r[1].length; i < len; i += 2)
for (let i = 0, len = r[1].length; i < len; i += 2)
attrs[r[1][i].toLowerCase()] = r[1][i + 1];

@@ -442,5 +457,6 @@ return {

function parseFetch(text, literals, seqno) {
var list = parseExpr(text, literals)[0], attrs = {}, m, body;
const list = parseExpr(text, literals)[0], attrs = {};
let m, body;
// list is [KEY1, VAL1, KEY2, VAL2, .... KEYn, VALn]
for (var i = 0, len = list.length, key, val; i < len; i += 2) {
for (let i = 0, len = list.length, key, val; i < len; i += 2) {
key = list[i].toLowerCase();

@@ -477,9 +493,10 @@ val = list[i + 1];

function parseBodyStructure(cur, literals, prefix, partID) {
var ret = [], i, len;
let ret = [];
let i, len;
if (prefix === undefined) {
var result = (Array.isArray(cur) ? cur : parseExpr(cur, literals));
const result = (Array.isArray(cur) ? cur : parseExpr(cur, literals));
if (result.length)
ret = parseBodyStructure(result, literals, '', 1);
} else {
var part, partLen = cur.length, next;
let part, partLen = cur.length, next;
if (Array.isArray(cur[0])) { // multipart

@@ -566,3 +583,3 @@ next = -1;

// ['Foo', ['Bar', 'Baz', 'Bam', 'Pow']]
var disposition = { type: null, params: null };
const disposition = { type: null, params: null };
if (Array.isArray(cur[next])) {

@@ -572,3 +589,3 @@ disposition.type = cur[next][0];

disposition.params = {};
for (var i = 0, len = cur[next][1].length, key; i < len; i += 2) {
for (let i = 0, len = cur[next][1].length, key; i < len; i += 2) {
key = cur[next][1][i].toLowerCase();

@@ -623,7 +640,8 @@ disposition.params[key] = decodeWords(cur[next][1][i + 1]);

function parseEnvelopeAddresses(list) {
var addresses = null;
let addresses = null;
if (Array.isArray(list)) {
addresses = [];
var inGroup = false, curGroup;
for (var i = 0, len = list.length, addr; i < len; ++i) {
let inGroup = false;
let curGroup;
for (let i = 0, len = list.length, addr; i < len; ++i) {
addr = list[i];

@@ -643,3 +661,3 @@ if (addr[2] === null) { // end of group addresses

} else { // regular user address
var info = {
const info = {
name: decodeWords(addr[0]),

@@ -666,3 +684,3 @@ mailbox: addr[2],

start = start || 0;
var inQuote = false,
let inQuote = false,
lastPos = start - 1,

@@ -682,3 +700,3 @@ isTop = false,

}
for (var i = start, len = o.str.length; i < len; ++i) {
for (let i = start, len = o.str.length; i < len; ++i) {
if (!inQuote) {

@@ -711,3 +729,3 @@ if (isBody) {

} else {
var innerResult = [];
const innerResult = [];
i = parseExpr(o, literals, innerResult, i + 1, useBrackets);

@@ -734,4 +752,6 @@ lastPos = i;

str = str.substring(1, str.length - 1);
var newstr = '', isEscaping = false, p = 0;
for (var i = 0, len = str.length; i < len; ++i) {
let newstr = '', isEscaping = false, p = 0;
for (let i = 0, len = str.length; i < len; ++i) {
if (str[i] === '\\') {

@@ -764,6 +784,6 @@ if (!isEscaping)

// can't handle natively, so we'll just keep it as a string if it's too big
var val = parseInt(str, 10);
const val = parseInt(str, 10);
return (val.toString() === str ? val : str);
} else if (literals && literals.length && str === LITPLACEHOLDER) {
var l = literals.shift();
let l = literals.shift();
if (Buffer.isBuffer(l))

@@ -778,4 +798,4 @@ l = l.toString('utf8');

function repeat(chr, len) {
var s = '';
for (var i = 0; i < len; ++i)
let s = '';
for (let i = 0; i < len; ++i)
s += chr;

@@ -793,3 +813,3 @@ return s;

// something that's decodable
var newbuf = Buffer.alloc(state.buffer.length + buf.length); //new Buffer(state.buffer.length + buf.length);
const newbuf = Buffer.alloc(state.buffer.length + buf.length); //new Buffer(state.buffer.length + buf.length);
state.buffer.copy(newbuf, 0);

@@ -808,3 +828,3 @@ buf.copy(newbuf, state.buffer.length);

}
var ret, isPartial = false;
let ret, isPartial = false;
if (state.remainder !== undefined) {

@@ -826,3 +846,3 @@ // use cached remainder from the previous lookahead

// if not, the current buffer is partial
var lookahead, lookaheadBuf = Buffer.alloc(buf.length + nextBuf.length); //new Buffer(buf.length + nextBuf.length);
let lookahead, lookaheadBuf = Buffer.alloc(buf.length + nextBuf.length); //new Buffer(buf.length + nextBuf.length);
buf.copy(lookaheadBuf);

@@ -905,3 +925,3 @@ nextBuf.copy(lookaheadBuf, buf.length);

function decodeWords(str, state) {
var pendoffset = -1;
let pendoffset = -1;

@@ -921,3 +941,4 @@ if (!state) {

var bytes, m, next, i, j, leni, lenj, seq, replaces = [], lastReplace = {};
let bytes, m, next, i, j, leni, lenj, seq;
let replaces = [], lastReplace = {};

@@ -995,4 +1016,3 @@ // join consecutive q-encoded words that have the same charset first

function parseHeader(str, noDecode) {
var lines = str.split(RE_CRLF),
len = lines.length,
const lines = str.split(RE_CRLF),
header = {},

@@ -1006,4 +1026,5 @@ state = {

remainder: undefined
},
m, h, i, val;
};
let len = lines.length;
let m, h, i, val;

@@ -1043,3 +1064,3 @@ for (i = 0; i < len; ++i) {

if (!noDecode) {
var hvs;
let hvs;
for (h in header) {

@@ -1046,0 +1067,0 @@ hvs = header[h];

@@ -0,1 +1,3 @@

'use strict';
const RE_NUM_RANGE = /^(?:[\d]+|\*):(?:[\d]+|\*)$/,

@@ -2,0 +4,0 @@ RE_BACKSLASH = /\\/g,

{
"name": "node-imap",
"version": "0.9.0",
"version": "0.9.1",
"author": "Brian White <mscdex@mscdex.net>",
"description": "An IMAP module for node.js that makes communicating with IMAP servers easy",
"description": "A fork of the famous and outdated IMAP module for node.js that makes communicating with IMAP servers easy",
"main": "./lib/Connection",

@@ -7,0 +7,0 @@ "license": "MIT",

@@ -41,2 +41,26 @@ var Parser = require('../lib/Parser').Parser;

},
{ source: ['A1 NO [ALERT] Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)', CRLF],
expected: [ {
type: 'no',
tagnum: 1,
textCode: 'ALERT',
text: 'Please log in via your web browser: https://support.google.com/mail/accounts/answer/78754 (Failure)'
}
],
what: 'Continuation with text code'
},
{ source: ['* NO [WEBALERT https://someurl.com/continue?sarp=1&scc=1] Web login required.', CRLF],
expected: [ {
type: 'no',
num: undefined,
textCode: {
key: 'WEBALERT',
val: 'https://someurl.com/continue?sarp=1&scc=1'
},
text: 'Web login required.'
}
],
what: 'Handling of Webalert'
},
{ source: ['+', CRLF],

@@ -43,0 +67,0 @@ expected: [ { textCode: undefined,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc