Socket
Socket
Sign inDemoInstall

saxen

Package Overview
Dependencies
0
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.7.0 to 6.0.1

10

CHANGELOG.md

@@ -9,2 +9,12 @@ # Changelog

## 6.0.1
_This is a re-publish of the broken `v6.0.0` version_
* `FEAT`: recover from attribute parse errors; instead of skipping attributes all together attempt to parse what's possible [#13](https://github.com/nikku/saxen/issues/13)
## 6.0.0
_Unpublished; Use `v6.0.1` instead._
## 5.7.0

@@ -11,0 +21,0 @@

10

package.json

@@ -17,3 +17,3 @@ {

],
"version": "5.7.0",
"version": "6.0.1",
"main": "./parser.js",

@@ -35,8 +35,2 @@ "bugs": {

"license": "MIT",
"files": [
"parser.js",
"decode.js",
"LICENSE",
"README.md"
],
"repository": {

@@ -48,3 +42,3 @@ "type": "git",

"eslint": "^4.9.0",
"eslint-plugin-mocha": "^4.11.0",
"eslint-plugin-bpmn-io": "^0.5.2",
"mocha": "^4.0.1",

@@ -51,0 +45,0 @@ "npm-run-all": "^4.1.1",

117

parser.js

@@ -311,10 +311,12 @@ 'use strict';

seenAttrs = {},
skipAttr,
w,
j;
parseAttr:
for (; i < l; i++) {
skipAttr = false;
w = s.charCodeAt(i);
if (w === 32 || (w < 14 && w > 8) ) { // \f\n\r\t\v
if (w === 32 || (w < 14 && w > 8)) { // WHITESPACE={ \f\n\r\t\v}
continue;

@@ -324,6 +326,6 @@ }

// wait for non whitespace character
if (w < 65 || w > 122 || (w > 90 && w < 97) ) {
if (w < 65 || w > 122 || (w > 90 && w < 97)) {
if (w !== 95 && w !== 58) { // char 95"_" 58":"
handleWarning('illegal first char attribute name');
return cachedAttrs = false;
skipAttr = true;
}

@@ -336,13 +338,21 @@ }

if ( w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 45 || w === 95) {
if (w > 96 && w < 123 || w > 64 && w < 91 || w > 47 && w < 59 || w === 45 || w === 95) {
continue;
}
if (w !== 61) { // "=" == 61
// expected "="
// unexpected whitespace
if (w === 32 || (w < 14 && w > 8)) { // WHITESPACE
handleWarning('missing attribute value');
return cachedAttrs = false;
i = j;
continue parseAttr;
}
break;
// expected "="
if (w === 61) { // "=" == 61
break;
}
handleWarning('illegal attribute name char');
skipAttr = true;
}

@@ -354,3 +364,3 @@

handleWarning('illegal declaration of xmlns');
return cachedAttrs = false; // error. invalid name
skipAttr = true;
}

@@ -360,35 +370,78 @@

if (w === 34) { // '"'
j = s.indexOf('"', i = j + 2 );
if (w === 34) { // '"'
j = s.indexOf('"', i = j + 2);
if (j === -1) {
j = s.indexOf('\'', i);
if (j !== -1) {
handleWarning('attribute value quote missmatch');
skipAttr = true;
}
}
} else if (w === 39) { // "'"
j = s.indexOf('\'', i = j + 2);
if (j === -1) {
j = s.indexOf('"', i);
if (j !== -1) {
handleWarning('attribute value quote missmatch');
skipAttr = true;
}
}
} else {
if (w !== 39) { // "'"
handleWarning('missing attribute value quotes');
return cachedAttrs = false; // error. invalid char
handleWarning('missing attribute value quotes');
skipAttr = true;
// skip to next space
for (j = j + 1; j < l; j++) {
w = s.charCodeAt(j + 1);
if (w === 32 || (w < 14 && w > 8)) { // WHITESPACE
break;
}
}
j = s.indexOf('\'', i = j + 2 );
}
if (j === -1) {
handleWarning('attribute value quote missmatch');
return cachedAttrs = false; // error. invalid char
handleWarning('missing closing quotes');
j = l;
skipAttr = true;
}
if (j + 1 < l) {
if (!skipAttr) {
value = s.substring(i, j);
}
i = j;
// ensure SPACE follows attribute
// skip illegal content otherwise
// example a="b"c
for (; j + 1 < l; j++) {
w = s.charCodeAt(j + 1);
if (w > 32 || w < 9 || (w < 32 && w > 13)) {
// error. invalid char
if (w === 32 || (w < 14 && w > 8)) { // WHITESPACE
break;
}
// FIRST ILLEGAL CHAR
if (i === j) {
handleWarning('illegal character after attribute end');
return cachedAttrs = false;
skipAttr = true;
}
}
value = s.substring(i, j);
// advance cursor to next attribute
i = j + 1;
if (skipAttr) {
continue parseAttr;
}
// check attribute re-declaration

@@ -507,3 +560,3 @@ if (name in seenAttrs) {

// handle deferred, possibly namespaced attributes
if (maybeNS) {
if (maybeNS) {

@@ -715,3 +768,3 @@ // normalize captured attributes

j = xml.indexOf('?>', i);
if (j === -1) { // error
if (j === -1) {
return handleError('unclosed question');

@@ -733,3 +786,3 @@ }

if (j == -1) { // error
if (j == -1) {
return handleError('unclosed tag');

@@ -742,3 +795,3 @@ }

//if (xml.charCodeAt(i+1) === 47) { // </...
// if (xml.charCodeAt(i+1) === 47) { // </...
if (w === 47) { // </...

@@ -764,3 +817,3 @@ tagStart = false;

if (w === 32 || (w > 8 && w < 14)) { // \f\n\r\t\v space
if (w === 32 || (w > 8 && w < 14)) { // \f\n\r\t\v space
continue;

@@ -773,3 +826,3 @@ }

} else {
if (xml.charCodeAt(j - 1) === 47) { // .../>
if (xml.charCodeAt(j - 1) === 47) { // .../>
x = elementName = xml.substring(i + 1, j - 1);

@@ -787,3 +840,3 @@

if (!(w > 96 && w < 123 || w > 64 && w < 91 || w === 95 || w === 58)) { // char 95"_" 58":"
if (!(w > 96 && w < 123 || w > 64 && w < 91 || w === 95 || w === 58)) { // char 95"_" 58":"
return handleError('illegal first char nodeName');

@@ -790,0 +843,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc