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

imapflow

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imapflow - npm Package Compare versions

Comparing version 1.0.155 to 1.0.156

7

CHANGELOG.md
# Changelog
## [1.0.156](https://github.com/postalsys/imapflow/compare/v1.0.155...v1.0.156) (2024-03-07)
### Bug Fixes
* micro-optimizations for parser ([3451ad2](https://github.com/postalsys/imapflow/commit/3451ad235532ca1a64a829f9f2f8e77bcef3a17d))
## [1.0.155](https://github.com/postalsys/imapflow/compare/v1.0.154...v1.0.155) (2024-03-06)

@@ -4,0 +11,0 @@

85

lib/handler/token-parser.js

@@ -7,2 +7,13 @@ /* eslint new-cap: 0 */

const STATE_ATOM = 0x001;
const STATE_LITERAL = 0x002;
const STATE_NORMAL = 0x003;
const STATE_PARTIAL = 0x004;
const STATE_SEQUENCE = 0x005;
const STATE_STRING = 0x006;
const STATE_TEXT = 0x007;
const RE_DIGITS = /^\d+$/;
const RE_SINGLE_DIGIT = /^\d$/;
class TokenParser {

@@ -19,3 +30,3 @@ constructor(parent, startPos, str, options) {

this.state = 'NORMAL';
this.state = STATE_NORMAL;
}

@@ -137,3 +148,3 @@

switch (this.state) {
case 'NORMAL':
case STATE_NORMAL:
switch (chr) {

@@ -144,3 +155,3 @@ // DQUOTE starts a new string

this.currentNode.type = 'string';
this.state = 'STRING';
this.state = STATE_STRING;
this.currentNode.isClosed = false;

@@ -193,7 +204,7 @@ break;

this.currentNode.value = chr;
this.state = 'ATOM';
this.state = STATE_ATOM;
} else {
this.currentNode = this.createNode(this.currentNode, this.pos + i);
this.currentNode.type = 'PARTIAL';
this.state = 'PARTIAL';
this.state = STATE_PARTIAL;
this.currentNode.isClosed = false;

@@ -212,3 +223,3 @@ }

this.currentNode.value = chr;
this.state = 'ATOM';
this.state = STATE_ATOM;
break;

@@ -232,3 +243,3 @@ }

this.expectedLiteralType = false;
this.state = 'LITERAL';
this.state = STATE_LITERAL;
this.currentNode.isClosed = false;

@@ -243,3 +254,3 @@ break;

this.currentNode.isClosed = false;
this.state = 'SEQUENCE';
this.state = STATE_SEQUENCE;
break;

@@ -264,3 +275,3 @@

this.currentNode.isClosed = false;
this.state = 'NORMAL';
this.state = STATE_NORMAL;

@@ -315,3 +326,3 @@ // RFC2221 defines a response code REFERRAL whose payload is an

this.currentNode.value = chr;
this.state = 'ATOM';
this.state = STATE_ATOM;
break;

@@ -321,3 +332,3 @@ }

case 'ATOM':
case STATE_ATOM:
// space finishes an atom

@@ -327,3 +338,3 @@ if (chr === ' ') {

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
break;

@@ -343,3 +354,3 @@ }

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
checkSP();

@@ -350,6 +361,6 @@

if ((chr === ',' || chr === ':') && this.currentNode.value.match(/^\d+$/)) {
if ((chr === ',' || chr === ':') && RE_DIGITS.test(this.currentNode.value)) {
this.currentNode.type = 'SEQUENCE';
this.currentNode.isClosed = true;
this.state = 'SEQUENCE';
this.state = STATE_SEQUENCE;
}

@@ -370,3 +381,3 @@

this.currentNode.isClosed = false;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
break;

@@ -404,3 +415,3 @@ }

case 'STRING':
case STATE_STRING:
// DQUOTE ends the string sequence

@@ -411,3 +422,3 @@ if (chr === '"') {

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;

@@ -433,5 +444,5 @@ checkSP();

case 'PARTIAL':
case STATE_PARTIAL:
if (chr === '>') {
if (this.currentNode.value.substr(-1) === '.') {
if (this.currentNode.value.at(-1) === '.') {
let error = new Error(`Unexpected end of partial at position ${this.pos + 1} [E19]`);

@@ -445,3 +456,3 @@ error.code = 'ParserError19';

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
checkSP();

@@ -475,3 +486,3 @@ break;

case 'LITERAL':
case STATE_LITERAL:
if (this.currentNode.started) {

@@ -496,3 +507,3 @@ // only relevant if literals are not already parsed out from input

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
checkSP();

@@ -534,3 +545,3 @@ }

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
checkSP();

@@ -553,3 +564,3 @@ } else if (this.options.literals) {

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
checkSP();

@@ -580,6 +591,6 @@ } else {

case 'SEQUENCE':
case STATE_SEQUENCE:
// space finishes the sequence set
if (chr === ' ') {
if (!this.currentNode.value.substr(-1).match(/\d/) && this.currentNode.value.substr(-1) !== '*') {
if (!RE_SINGLE_DIGIT.test(this.currentNode.value.at(-1)) && this.currentNode.value.at(-1) !== '*') {
let error = new Error(`Unexpected whitespace at position ${this.pos + i} [E27]`);

@@ -591,3 +602,3 @@ error.code = 'ParserError27';

if (this.currentNode.value !== '*' && this.currentNode.value.substr(-1) === '*' && this.currentNode.value.substr(-2, 1) !== ':') {
if (this.currentNode.value !== '*' && this.currentNode.value.at(-1) === '*' && this.currentNode.value.at(-2) !== ':') {
let error = new Error(`Unexpected whitespace at position ${this.pos + i} [E28]`);

@@ -602,3 +613,3 @@ error.code = 'ParserError28';

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;
break;

@@ -612,3 +623,3 @@ } else if (this.currentNode.parentNode && chr === ']' && this.currentNode.parentNode.type === 'SECTION') {

this.currentNode = this.currentNode.parentNode;
this.state = 'NORMAL';
this.state = STATE_NORMAL;

@@ -620,3 +631,3 @@ checkSP();

if (chr === ':') {
if (!this.currentNode.value.substr(-1).match(/\d/) && this.currentNode.value.substr(-1) !== '*') {
if (!RE_SINGLE_DIGIT.test(this.currentNode.value.at(-1)) && this.currentNode.value.at(-1) !== '*') {
let error = new Error(`Unexpected range separator : at position ${this.pos + i} [E29]`);

@@ -628,3 +639,3 @@ error.code = 'ParserError29';

} else if (chr === '*') {
if ([',', ':'].indexOf(this.currentNode.value.substr(-1)) < 0) {
if ([',', ':'].indexOf(this.currentNode.value.at(-1)) < 0) {
let error = new Error(`Unexpected range wildcard at position ${this.pos + i} [E30]`);

@@ -636,3 +647,3 @@ error.code = 'ParserError30';

} else if (chr === ',') {
if (!this.currentNode.value.substr(-1).match(/\d/) && this.currentNode.value.substr(-1) !== '*') {
if (!RE_SINGLE_DIGIT.test(this.currentNode.value.at(-1)) && this.currentNode.value.at(-1) !== '*') {
let error = new Error(`Unexpected sequence separator , at position ${this.pos + i} [E31]`);

@@ -643,3 +654,3 @@ error.code = 'ParserError31';

}
if (this.currentNode.value.substr(-1) === '*' && this.currentNode.value.substr(-2, 1) !== ':') {
if (this.currentNode.value.at(-1) === '*' && this.currentNode.value.at(-2) !== ':') {
let error = new Error(`Unexpected sequence separator , at position ${this.pos + i} [E32]`);

@@ -650,3 +661,3 @@ error.code = 'ParserError32';

}
} else if (!chr.match(/\d/)) {
} else if (!RE_SINGLE_DIGIT.test(chr)) {
let error = new Error(`Unexpected char at position ${this.pos + i} [E33: ${JSON.stringify(chr)}]`);

@@ -658,3 +669,3 @@ error.code = 'ParserError33';

if (chr.match(/\d/) && this.currentNode.value.substr(-1) === '*') {
if (RE_SINGLE_DIGIT.test(chr) && this.currentNode.value.at(-1) === '*') {
let error = new Error(`Unexpected number at position ${this.pos + i} [E34: ${JSON.stringify(chr)}]`);

@@ -669,3 +680,3 @@ error.code = 'ParserError34';

case 'TEXT':
case STATE_TEXT:
this.currentNode.value += chr;

@@ -672,0 +683,0 @@ break;

{
"name": "imapflow",
"version": "1.0.155",
"version": "1.0.156",
"description": "IMAP Client for Node",

@@ -5,0 +5,0 @@ "main": "./lib/imap-flow.js",

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