Socket
Socket
Sign inDemoInstall

csv-parse

Package Overview
Dependencies
0
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.2.0 to 5.2.1

44

lib/api/index.js

@@ -11,11 +11,5 @@

// white space characters
// https://en.wikipedia.org/wiki/Whitespace_character
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes#Types
// \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff
const tab = 9;
const nl = 10; // \n, 0x0A in hexadecimal, 10 in decimal
const np = 12;
const cr = 13; // \r, 0x0D in hexadécimal, 13 in decimal
const space = 32;
const cr = 13; // `\r`, carriage return, 0x0D in hexadécimal, 13 in decimal
const nl = 10; // `\n`, newline, 0x0A in hexadecimal, 10 in decimal
const boms = {

@@ -165,3 +159,3 @@ // Note, the following are equals:

const nextChr = buf[pos+quote.length];
const isNextChrTrimable = rtrim && this.__isCharTrimable(nextChr);
const isNextChrTrimable = rtrim && this.__isCharTrimable(buf, pos+quote.length);
const isNextChrComment = comment !== null && this.__compareBytes(comment, buf, pos+quote.length, nextChr);

@@ -276,3 +270,3 @@ const isNextChrDelimiter = this.__isDelimiter(buf, pos+quote.length, nextChr);

if(max_record_size !== 0 && this.state.record_length + this.state.field.length > max_record_size){
const err = this.__error(
return this.__error(
new CsvError('CSV_MAX_RECORD_SIZE', [

@@ -285,6 +279,5 @@ 'Max Record Size:',

);
if(err !== undefined) return err;
}
}
const lappend = ltrim === false || this.state.quoting === true || this.state.field.length !== 0 || !this.__isCharTrimable(chr);
const lappend = ltrim === false || this.state.quoting === true || this.state.field.length !== 0 || !this.__isCharTrimable(buf, pos);
// rtrim in non quoting is handle in __onField

@@ -294,4 +287,4 @@ const rappend = rtrim === false || this.state.wasQuoting === false;

this.state.field.append(chr);
}else if(rtrim === true && !this.__isCharTrimable(chr)){
const err = this.__error(
}else if(rtrim === true && !this.__isCharTrimable(buf, pos)){
return this.__error(
new CsvError('CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE', [

@@ -303,3 +296,7 @@ 'Invalid Closing Quote:',

);
if(err !== undefined) return err;
}else{
if(lappend === false){
pos += this.__isCharTrimable(buf, pos) - 1;
}
continue;
}

@@ -561,4 +558,15 @@ }

// Helper to test if a character is a space or a line delimiter
__isCharTrimable: function(chr){
return chr === space || chr === tab || chr === cr || chr === nl || chr === np;
__isCharTrimable: function(buf, pos){
const isTrim = (buf, pos) => {
const {timchars} = this.state;
loop1: for(let i = 0; i < timchars.length; i++){
const timchar = timchars[i];
for(let j = 0; j < timchar.length; j++){
if(timchar[j] !== buf[pos+j]) continue loop1;
}
return timchar.length;
}
return 0;
};
return isTrim(buf, pos);
},

@@ -565,0 +573,0 @@ // Keep it in case we implement the `cast_int` option

import ResizeableBuffer from '../utils/ResizeableBuffer.js';
// white space characters
// https://en.wikipedia.org/wiki/Whitespace_character
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions/Character_Classes#Types
// \f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff
const np = 12;
const cr = 13; // `\r`, carriage return, 0x0D in hexadécimal, 13 in decimal
const nl = 10; // `\n`, newline, 0x0A in hexadecimal, 10 in decimal
const space = 32;
const tab = 9;
const init_state = function(options){

@@ -37,3 +47,10 @@ return {

wasQuoting: false,
wasRowDelimiter: false
wasRowDelimiter: false,
timchars: [
Buffer.from(Buffer.from([cr], 'utf8').toString(), options.encoding),
Buffer.from(Buffer.from([nl], 'utf8').toString(), options.encoding),
Buffer.from(Buffer.from([np], 'utf8').toString(), options.encoding),
Buffer.from(Buffer.from([space], 'utf8').toString(), options.encoding),
Buffer.from(Buffer.from([tab], 'utf8').toString(), options.encoding),
]
};

@@ -40,0 +57,0 @@ };

{
"version": "5.2.0",
"version": "5.2.1",
"name": "csv-parse",

@@ -119,3 +119,3 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API",

},
"gitHead": "851a129b5c57c5c77e49fee3587a0d4afb91c683"
"gitHead": "e8b4fc755271b6d0bbd44deb3ef59ac07cc666f3"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc