Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-expat

Package Overview
Dependencies
Maintainers
2
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-expat - npm Package Compare versions

Comparing version 2.1.4 to 2.2.0

4

lib/node-expat.js

@@ -25,2 +25,6 @@ var EventEmitter = require('events').EventEmitter;

Parser.prototype.setUnknownEncoding = function(map, convert) {
return this.parser.setUnknownEncoding(map, convert);
};
Parser.prototype.getError = function() {

@@ -27,0 +31,0 @@ return this.parser.getError();

8

package.json
{
"name": "node-expat",
"version": "2.1.4",
"version": "2.2.0",
"main": "./lib/node-expat",

@@ -21,3 +21,4 @@ "description": "NodeJS binding for fast XML parsing.",

"devDependencies": {
"vows": ">=0.5.12"
"vows": ">=0.5.12",
"iconv": "~2.1.0"
},

@@ -54,3 +55,4 @@ "repository": {

"Tom Hughes-Croucher",
"Nathan Rajlich"
"Nathan Rajlich",
"Julien Genestoux"
],

@@ -57,0 +59,0 @@ "licenses": [

var expat = require('./lib/node-expat');
var Iconv = require('iconv').Iconv;
var Buffer = require('buffer').Buffer;

@@ -27,3 +28,3 @@ var vows = require('vows');

for(var step = s.length; step > 0; step--) {
expectWithParserAndStep(s, evs_expected, new expat.Parser("UTF-8"), step);
expectWithParserAndStep(s, evs_expected, new expat.Parser(), step);
}

@@ -34,3 +35,2 @@ }

var evs_received = [];
//p.setEncoding("UTF-8");
p.addListener('startElement', function(name, attrs) {

@@ -176,2 +176,63 @@ evs_received.push(['startElement', name, attrs]);

},
'unknownEncoding with single-byte map': {
'Windows-1252': function() {
var p = new expat.Parser();
var encodingName;
p.addListener('unknownEncoding', function(name) {
encodingName = name;
var map = [];
for(var i = 0; i < 256; i++)
map[i] = i;
map[165] = 0x00A5; // ¥
map[128] = 0x20AC; // €
map[ 36] = 0x0024; // $
p.setUnknownEncoding(map);
});
var text = "";
p.addListener('text', function(s) {
text += s;
});
p.addListener('error', function(e) {
assert.fail(e);
});
p.parse("<?xml version='1.0' encoding='Windows-1252'?><r>");
p.parse(new Buffer([165, 128, 36]));
p.parse("</r>");
assert.equal(encodingName, "Windows-1252");
assert.equal(text, "¥€$");
}
},
'unknownEncoding with single-byte map using iconv': {
'Windows-1252': function() {
var p = new expat.Parser();
var encodingName;
p.addListener('unknownEncoding', function(name) {
encodingName = name;
var iconv = new Iconv(encodingName + '//TRANSLIT//IGNORE', 'UTF-8');
var map = [];
for(var i = 0; i < 256; i++) {
try {
var d = iconv.convert(new Buffer([i])).toString();
} catch (e) {
d = '\b';
}
map[i] = d.charCodeAt(0);
}
p.setUnknownEncoding(map);
});
var text = "";
p.addListener('text', function(s) {
text += s;
});
p.addListener('error', function(e) {
assert.fail(e);
});
p.parse("<?xml version='1.0' encoding='Windows-1252'?><r>");
p.parse(new Buffer([165, 128, 36]));
p.parse("</r>");
assert.equal(encodingName, "Windows-1252");
assert.equal("¥€$", text);
}
},
'error': {

@@ -178,0 +239,0 @@ 'tag name starting with ampersand': function() {

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 not supported yet

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