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 3.0.1 to 3.1.0

5

CHANGELOG.md

@@ -0,1 +1,6 @@

# 3.1.0
* `FEAT`: keep non-decodeable entities _as is_
* `FEAT`: decode only [required sub-set](https://www.w3.org/TR/REC-xml/#sec-predefined-ent) of named entities
# 3.0.1

@@ -2,0 +7,0 @@

2

package.json

@@ -16,3 +16,3 @@ {

],
"version": "3.0.1",
"version": "3.1.0",
"main": "./parser.js",

@@ -19,0 +19,0 @@ "bugs": {

@@ -16,22 +16,7 @@ 'use strict';

var SPECIAL_CHARS_MAPPING = {
quot: '"',
QUOT: '"',
amp: '&',
AMP: '&',
nbsp: '\u00A0',
apos: '\'',
gt: '>',
lt: '<',
LT: '<',
gt: '>',
GT: '>',
copy: '\u00A9',
laquo: '\u00AB',
raquo: '\u00BB',
reg: '\u00AE',
deg: '\u00B0',
plusmn: '\u00B1',
sup2: '\u00B2',
sup3: '\u00B3',
micro: '\u00B5',
para: '\u00B6'
quot: '"'
};

@@ -53,7 +38,24 @@

function replaceEntities(s, d, x, z) {
function replaceEntities(_, d, x, z) {
var _z;
// reserved names, i.e. &nbsp;
if (z) {
return hasProperty(SPECIAL_CHARS_MAPPING, z) && SPECIAL_CHARS_MAPPING[z] || '\x01';
if (hasProperty(SPECIAL_CHARS_MAPPING, z)) {
return SPECIAL_CHARS_MAPPING[z];
}
_z = z.toLowerCase();
if (hasProperty(SPECIAL_CHARS_MAPPING, _z)) {
return SPECIAL_CHARS_MAPPING[_z];
}
// return original char, as we don't understand the
// user input
return '&' + z + ';';
}
// decimal encoded char
if (d) {

@@ -63,2 +65,3 @@ return fromCharCode(d);

// hex encoded char
return fromCharCode(parseInt(x, 16));

@@ -71,8 +74,4 @@ }

if (s.length > 3 && s.indexOf('&') !== -1) {
if (s.indexOf('&quot;') !== -1) s = s.replace(/&quot;/g, '"');
if (s.indexOf('&gt;') !== -1) s = s.replace(/&gt;/g, '>');
if (s.indexOf('&lt;') !== -1) s = s.replace(/&lt;/g, '<');
if (s.indexOf('&') !== -1) {
s = s.replace(/&#(\d+);|&#x([0123456789abcdef]+);|&(\w+);/ig, replaceEntities);
return s.replace(/&#(\d+);|&#x([0-9a-f]+);|&(\w+);/ig, replaceEntities);
}

@@ -133,5 +132,5 @@ }

var onTextNode = nullFunc,
onStartNode = nullFunc,
onEndNode = nullFunc,
var onText = nullFunc,
onOpenTag = nullFunc,
onCloseTag = nullFunc,
onCDATA = nullFunc,

@@ -217,5 +216,5 @@ onError = throwFunc,

switch (name) {
case 'openTag': onStartNode = cb; break;
case 'text': onTextNode = cb; break;
case 'closeTag': onEndNode = cb; break;
case 'openTag': onOpenTag = cb; break;
case 'text': onText = cb; break;
case 'closeTag': onCloseTag = cb; break;
case 'error': onError = cb; break;

@@ -682,3 +681,3 @@ case 'warn': onWarning = cb; break;

if (j !== i) {
onTextNode(xml.substring(j, i), decodeEntities);
onText(xml.substring(j, i), decodeEntities);
if (parseStop) {

@@ -889,5 +888,5 @@ return;

if (proxy) {
onStartNode(elementProxy, decodeEntities, tagEnd, getContext);
onOpenTag(elementProxy, decodeEntities, tagEnd, getContext);
} else {
onStartNode(elementName, getAttrs, decodeEntities, tagEnd, getContext);
onOpenTag(elementName, getAttrs, decodeEntities, tagEnd, getContext);
}

@@ -903,3 +902,3 @@

if (tagEnd) {
onEndNode(proxy ? elementProxy : elementName, decodeEntities, tagStart, getContext);
onCloseTag(proxy ? elementProxy : elementName, decodeEntities, tagStart, getContext);

@@ -906,0 +905,0 @@ if (parseStop) {

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