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

moddle-xml

Package Overview
Dependencies
Maintainers
3
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moddle-xml - npm Package Compare versions

Comparing version 2.1.1 to 2.2.0

20

lib/reader.js

@@ -710,2 +710,21 @@ 'use strict';

var ENCODING_PATTERN = /^<\?xml.* encoding="([^"]+)"(?: .*)?\?>$/i;
var UTF_8_PATTERN = /^utf-8$/i;
function handleQuestion(question) {
var match = ENCODING_PATTERN.exec(question);
var encoding = match && match[1];
if (!encoding || UTF_8_PATTERN.test(encoding)) {
return;
}
context.addWarning({
message:
'unsupported document encoding <' + encoding + '>, ' +
'falling back to UTF-8'
});
}
function handleOpen(node, getContext) {

@@ -770,2 +789,3 @@ var handler = stack.peek();

})
.on('question', handleQuestion)
.on('closeTag', handleClose)

@@ -772,0 +792,0 @@ .on('cdata', handleCData)

2

package.json
{
"name": "moddle-xml",
"version": "2.1.1",
"version": "2.2.0",
"description": "XML import/export for documents described with moddle",

@@ -5,0 +5,0 @@ "directories": {

@@ -2097,2 +2097,66 @@ 'use strict';

describe('encoding', function() {
var model = createModel([ 'properties' ]);
it('should decode UTF-8, no problemo', function(done) {
// given
var reader = new Reader(model);
var rootHandler = reader.handler('props:ComplexAttrs');
var xml =
'<?xml version="1.0" encoding="utf-8"?>' +
'<props:complexAttrs xmlns:props="http://properties">' +
'</props:complexAttrs>';
// when
reader.fromXML(xml, rootHandler, function(err, result, context) {
// then
expect(err).not.to.exist;
expect(context.warnings).to.be.empty;
expect(result).to.exist;
expect(context).to.exist;
done();
});
});
it('should warn on non-UTF-8 encoded files', function(done) {
// given
var reader = new Reader(model);
var rootHandler = reader.handler('props:ComplexAttrs');
var xml =
'<?xml version="1.0" encoding="windows-1252"?>' +
'<props:complexAttrs xmlns:props="http://properties">' +
'</props:complexAttrs>';
// when
reader.fromXML(xml, rootHandler, function(err, result, context) {
// then
expect(err).not.to.exist;
var warnings = context.warnings;
expect(warnings).to.have.length(1);
expect(warnings[0].message).to.match(/unsupported document encoding <windows-1252>/);
expect(result).to.exist;
expect(context).to.exist;
done();
});
});
});
});
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