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

rdfxml-streaming-parser

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rdfxml-streaming-parser - npm Package Compare versions

Comparing version 1.2.2 to 1.2.3

6

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file.
<a name="v1.2.3"></a>
## [v1.2.3](https://github.com/rdfjs/rdfxml-streaming-parser.js/compare/v1.2.2...v1.2.3) - 2019-04-25
### Fixed
* [Fix stream transformation continuing after first error, #12](https://github.com/rdfjs/rdfxml-streaming-parser.js/commit/acc805b1b963067eae8e7583bc6debe4ec198e3e)
<a name="v1.2.2"></a>

@@ -5,0 +11,0 @@ ## [v1.2.2](https://github.com/rdfjs/rdfxml-streaming-parser.js/compare/v1.2.1...v1.2.2) - 2019-04-25

4

lib/RdfXmlParser.d.ts

@@ -81,3 +81,3 @@ /// <reference types="node" />

*
* This will emit an error if the URI is invalid.
* This throw an error if the URI is invalid.
*

@@ -90,3 +90,3 @@ * @param {string} uri A URI string.

* Validate the given value as an NCName: https://www.w3.org/TR/xml-names/#NT-NCName
* If it is invalid, an error will be emitted.
* If it is invalid, an error will thrown emitted.
* @param {string} value A value.

@@ -93,0 +93,0 @@ */

@@ -145,3 +145,8 @@ "use strict";

_transform(chunk, encoding, callback) {
this.saxStream.write(chunk, encoding);
try {
this.saxStream.write(chunk, encoding);
}
catch (e) {
return callback(e);
}
callback();

@@ -164,3 +169,3 @@ }

*
* This will emit an error if the URI is invalid.
* This throw an error if the URI is invalid.
*

@@ -173,3 +178,3 @@ * @param {string} uri A URI string.

if (!RdfXmlParser.isValidIri(uri)) {
this.emit('error', new Error(`Invalid URI: ${uri}`));
throw new Error(`Invalid URI: ${uri}`);
}

@@ -180,3 +185,3 @@ return this.dataFactory.namedNode(uri);

* Validate the given value as an NCName: https://www.w3.org/TR/xml-names/#NT-NCName
* If it is invalid, an error will be emitted.
* If it is invalid, an error will thrown emitted.
* @param {string} value A value.

@@ -187,3 +192,3 @@ */

if (!RdfXmlParser.NCNAME_MATCHER.test(value)) {
this.emit('error', new Error(`Not a valid NCName: ${value}`));
throw new Error(`Not a valid NCName: ${value}`);
}

@@ -203,50 +208,45 @@ }

onTag(tag) {
try {
// Get parent tag
const parentTag = this.activeTagStack.length
? this.activeTagStack[this.activeTagStack.length - 1] : null;
let currentParseType = ParseType.RESOURCE;
if (parentTag) {
parentTag.hadChildren = true;
currentParseType = parentTag.childrenParseType;
// Get parent tag
const parentTag = this.activeTagStack.length
? this.activeTagStack[this.activeTagStack.length - 1] : null;
let currentParseType = ParseType.RESOURCE;
if (parentTag) {
parentTag.hadChildren = true;
currentParseType = parentTag.childrenParseType;
}
// Check if this tag needs to be converted to a string
if (parentTag && parentTag.childrenStringTags) {
// Convert this tag to a string
const tagName = tag.name;
let attributes = '';
for (const attributeKey in tag.attributes) {
attributes += ` ${attributeKey}="${tag.attributes[attributeKey]}"`;
}
// Check if this tag needs to be converted to a string
if (parentTag && parentTag.childrenStringTags) {
// Convert this tag to a string
const tagName = tag.name;
let attributes = '';
for (const attributeKey in tag.attributes) {
attributes += ` ${attributeKey}="${tag.attributes[attributeKey]}"`;
}
const tagContents = `${tagName}${attributes}`;
const tagString = `<${tagContents}>`;
parentTag.childrenStringTags.push(tagString);
// Inherit the array, so that deeper tags are appended to this same array
const stringActiveTag = { childrenStringTags: parentTag.childrenStringTags };
stringActiveTag.childrenStringEmitClosingTag = `</${tagName}>`;
this.activeTagStack.push(stringActiveTag);
// Halt any further processing
return;
}
const activeTag = {};
if (parentTag) {
// Inherit language scope and baseIRI from parent
activeTag.language = parentTag.language;
activeTag.baseIRI = parentTag.baseIRI;
}
else {
activeTag.baseIRI = this.baseIRI;
}
this.activeTagStack.push(activeTag);
activeTag.ns = RdfXmlParser.parseNamespace(tag, parentTag);
if (currentParseType === ParseType.RESOURCE) {
this.onTagResource(tag, activeTag, parentTag, !parentTag);
}
else { // currentParseType === ParseType.PROPERTY
this.onTagProperty(tag, activeTag, parentTag);
}
const tagContents = `${tagName}${attributes}`;
const tagString = `<${tagContents}>`;
parentTag.childrenStringTags.push(tagString);
// Inherit the array, so that deeper tags are appended to this same array
const stringActiveTag = { childrenStringTags: parentTag.childrenStringTags };
stringActiveTag.childrenStringEmitClosingTag = `</${tagName}>`;
this.activeTagStack.push(stringActiveTag);
// Halt any further processing
return;
}
catch (e) {
this.emit('error', e);
const activeTag = {};
if (parentTag) {
// Inherit language scope and baseIRI from parent
activeTag.language = parentTag.language;
activeTag.baseIRI = parentTag.baseIRI;
}
else {
activeTag.baseIRI = this.baseIRI;
}
this.activeTagStack.push(activeTag);
activeTag.ns = RdfXmlParser.parseNamespace(tag, parentTag);
if (currentParseType === ParseType.RESOURCE) {
this.onTagResource(tag, activeTag, parentTag, !parentTag);
}
else { // currentParseType === ParseType.PROPERTY
this.onTagProperty(tag, activeTag, parentTag);
}
}

@@ -268,3 +268,3 @@ /**

if (!rootTag && RdfXmlParser.FORBIDDEN_NODE_ELEMENTS.indexOf(tagExpanded.local) >= 0) {
this.emit('error', new Error(`Illegal node element name: ${tagExpanded.local}`));
throw new Error(`Illegal node element name: ${tagExpanded.local}`);
}

@@ -294,4 +294,4 @@ switch (tagExpanded.local) {

if (activeSubjectValue) {
this.emit('error', new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`));
throw new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
}

@@ -302,4 +302,4 @@ activeSubjectValue = attributeValue;

if (activeSubjectValue) {
this.emit('error', new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`));
throw new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
}

@@ -312,4 +312,4 @@ this.validateNcname(attributeValue);

if (activeSubjectValue) {
this.emit('error', new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`));
throw new Error(`Only one of rdf:about, rdf:nodeID and rdf:ID can be present, \
while ${attributeValue} and ${activeSubjectValue} where found.`);
}

@@ -321,4 +321,3 @@ this.validateNcname(attributeValue);

case 'bagID':
this.emit('error', new Error(`rdf:bagID is not supported.`));
continue;
throw new Error(`rdf:bagID is not supported.`);
case 'type':

@@ -329,10 +328,7 @@ // Emit the rdf:type later as named node instead of the default literal

case 'aboutEach':
this.emit('error', new Error(`rdf:aboutEach is not supported.`));
continue;
throw new Error(`rdf:aboutEach is not supported.`);
case 'aboutEachPrefix':
this.emit('error', new Error(`rdf:aboutEachPrefix is not supported.`));
continue;
throw new Error(`rdf:aboutEachPrefix is not supported.`);
case 'li':
this.emit('error', new Error(`rdf:li on node elements are not supported.`));
continue;
throw new Error(`rdf:li on node elements are not supported.`);
}

@@ -436,3 +432,3 @@ }

&& RdfXmlParser.FORBIDDEN_PROPERTY_ELEMENTS.indexOf(tagExpanded.local) >= 0) {
this.emit('error', new Error(`Illegal property element name: ${tagExpanded.local}`));
throw new Error(`Illegal property element name: ${tagExpanded.local}`);
}

@@ -457,6 +453,6 @@ activeTag.predicateSubPredicates = [];

if (activeSubSubjectValue) {
this.emit('error', new Error(`Found both rdf:resource (${propertyAttributeValue}) and rdf:nodeID (${activeSubSubjectValue}).`));
throw new Error(`Found both rdf:resource (${propertyAttributeValue}) and rdf:nodeID (${activeSubSubjectValue}).`);
}
if (parseType) {
this.emit('error', new Error(`rdf:parseType is not allowed on property elements with rdf:resource (${propertyAttributeValue})`));
throw new Error(`rdf:parseType is not allowed on property elements with rdf:resource (${propertyAttributeValue})`);
}

@@ -469,6 +465,6 @@ activeTag.hadChildren = true;

if (attributedProperty) {
this.emit('error', new Error(`Found both non-rdf:* property attributes and rdf:datatype (${propertyAttributeValue}).`));
throw new Error(`Found both non-rdf:* property attributes and rdf:datatype (${propertyAttributeValue}).`);
}
if (parseType) {
this.emit('error', new Error(`rdf:parseType is not allowed on property elements with rdf:datatype (${propertyAttributeValue})`));
throw new Error(`rdf:parseType is not allowed on property elements with rdf:datatype (${propertyAttributeValue})`);
}

@@ -479,9 +475,9 @@ activeTag.datatype = this.valueToUri(propertyAttributeValue, activeTag);

if (attributedProperty) {
this.emit('error', new Error(`Found both non-rdf:* property attributes and rdf:nodeID (${propertyAttributeValue}).`));
throw new Error(`Found both non-rdf:* property attributes and rdf:nodeID (${propertyAttributeValue}).`);
}
if (activeTag.hadChildren) {
this.emit('error', new Error(`Found both rdf:resource and rdf:nodeID (${propertyAttributeValue}).`));
throw new Error(`Found both rdf:resource and rdf:nodeID (${propertyAttributeValue}).`);
}
if (parseType) {
this.emit('error', new Error(`rdf:parseType is not allowed on property elements with rdf:nodeID (${propertyAttributeValue})`));
throw new Error(`rdf:parseType is not allowed on property elements with rdf:nodeID (${propertyAttributeValue})`);
}

@@ -494,14 +490,13 @@ this.validateNcname(propertyAttributeValue);

case 'bagID':
this.emit('error', new Error(`rdf:bagID is not supported.`));
continue;
throw new Error(`rdf:bagID is not supported.`);
case 'parseType':
// Validation
if (attributedProperty) {
this.emit('error', new Error(`rdf:parseType is not allowed when non-rdf:* property attributes are present`));
throw new Error(`rdf:parseType is not allowed when non-rdf:* property attributes are present`);
}
if (activeTag.datatype) {
this.emit('error', new Error(`rdf:parseType is not allowed on property elements with rdf:datatype (${activeTag.datatype.value})`));
throw new Error(`rdf:parseType is not allowed on property elements with rdf:datatype (${activeTag.datatype.value})`);
}
if (activeSubSubjectValue) {
this.emit('error', new Error(`rdf:parseType is not allowed on property elements with rdf:nodeID or rdf:resource (${activeSubSubjectValue})`));
throw new Error(`rdf:parseType is not allowed on property elements with rdf:nodeID or rdf:resource (${activeSubSubjectValue})`);
}

@@ -549,3 +544,3 @@ if (propertyAttributeValue === 'Resource') {

if (parseType || activeTag.datatype) {
this.emit('error', new Error(`Found illegal rdf:* properties on property element with attribute: ${propertyAttributeValue}`));
throw new Error(`Found illegal rdf:* properties on property element with attribute: ${propertyAttributeValue}`);
}

@@ -606,3 +601,3 @@ activeTag.hadChildren = true;

if (this.nodeIds[term.value]) {
this.emit('error', new Error(`Found multiple occurrences of rdf:ID='${term.value}'.`));
throw new Error(`Found multiple occurrences of rdf:ID='${term.value}'.`);
}

@@ -609,0 +604,0 @@ this.nodeIds[term.value] = true;

{
"name": "rdfxml-streaming-parser",
"version": "1.2.2",
"version": "1.2.3",
"description": "Streaming RDF/XML parser",

@@ -5,0 +5,0 @@ "keywords": [

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