Socket
Socket
Sign inDemoInstall

rdfxml-streaming-parser

Package Overview
Dependencies
19
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

15

lib/RdfXmlParser.d.ts

@@ -6,5 +6,5 @@ /// <reference types="node" />

import { Transform } from "readable-stream";
import { IriValidationStrategy } from "validate-iri";
import EventEmitter = NodeJS.EventEmitter;
export declare class RdfXmlParser extends Transform implements RDF.Sink<EventEmitter, RDF.Stream> {
static readonly IRI_REGEX: RegExp;
static readonly MIME_TYPE = "application/rdf+xml";

@@ -24,2 +24,3 @@ static readonly RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";

private readonly validateUri;
private readonly iriValidationStrategy;
private readonly activeTagStack;

@@ -29,9 +30,2 @@ private readonly nodeIds;

/**
* Check if the given IRI is valid.
* @param {string} iri A potential IRI.
* @return {boolean} If the given IRI is valid.
*/
static isValidIri(iri: string): boolean;
get uriValidationEnabled(): boolean;
/**
* Parses the given text stream into a quad stream.

@@ -154,2 +148,7 @@ * @param {NodeJS.EventEmitter} stream A text stream.

validateUri?: boolean;
/**
* Allows to customize the used IRI validation strategy using the `IriValidationStrategy` enumeration.
* By default, the "pragmatic" strategy is used.
*/
iriValidationStrategy?: IriValidationStrategy;
}

@@ -156,0 +155,0 @@ export interface IActiveTag {

@@ -9,2 +9,3 @@ "use strict";

const rdf_data_factory_1 = require("rdf-data-factory");
const validate_iri_1 = require("validate-iri");
class RdfXmlParser extends readable_stream_1.Transform {

@@ -31,2 +32,5 @@ constructor(args) {

}
if (!this.iriValidationStrategy) {
this.iriValidationStrategy = this.validateUri ? validate_iri_1.IriValidationStrategy.Pragmatic : validate_iri_1.IriValidationStrategy.None;
}
this.saxParser = new saxes_1.SaxesParser({ xmlns: true, position: this.trackPosition });

@@ -36,13 +40,2 @@ this.attachSaxListeners();

/**
* Check if the given IRI is valid.
* @param {string} iri A potential IRI.
* @return {boolean} If the given IRI is valid.
*/
static isValidIri(iri) {
return RdfXmlParser.IRI_REGEX.test(iri);
}
get uriValidationEnabled() {
return this.validateUri;
}
/**
* Parses the given text stream into a quad stream.

@@ -99,4 +92,5 @@ * @param {NodeJS.EventEmitter} stream A text stream.

// Validate URI
if (this.uriValidationEnabled && !RdfXmlParser.isValidIri(uri)) {
throw this.newParseError(`Invalid URI: ${uri}`);
const uriValidationResult = (0, validate_iri_1.validateIri)(uri, this.iriValidationStrategy);
if (uriValidationResult instanceof Error) {
throw this.newParseError(uriValidationResult.message);
}

@@ -570,4 +564,2 @@ return this.dataFactory.namedNode(uri);

exports.RdfXmlParser = RdfXmlParser;
// Regex for valid IRIs
RdfXmlParser.IRI_REGEX = /^([A-Za-z][A-Za-z0-9+-.]*):[^ "<>{}|\\\[\]`]*$/;
RdfXmlParser.MIME_TYPE = 'application/rdf+xml';

@@ -574,0 +566,0 @@ RdfXmlParser.RDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#';

{
"name": "rdfxml-streaming-parser",
"version": "2.1.0",
"version": "2.2.0",
"description": "Streaming RDF/XML parser",

@@ -98,5 +98,6 @@ "keywords": [

"readable-stream": "^4.0.0",
"saxes": "^6.0.0"
"saxes": "^6.0.0",
"validate-iri": "^1.0.0"
},
"sideEffects": false
}

@@ -93,3 +93,3 @@ # RDF/XML Streaming Parser

* `dataFactory`: A custom [RDFJS DataFactory](http://rdf.js.org/#datafactory-interface) to construct terms and triples. _(Default: `require('@rdfjs/data-model')`)_
* `baseIRI`: An initital default base IRI. _(Default: `''`)_
* `baseIRI`: An initial default base IRI. _(Default: `''`)_
* `defaultGraph`: The default graph for constructing [quads](http://rdf.js.org/#dom-datafactory-quad). _(Default: `defaultGraph()`)_

@@ -100,2 +100,3 @@ * `strict`: If the internal SAX parser should parse XML in strict mode, and error if it is invalid. _(Default: `false`)_

* `validateUri`: By default, the parser validates each URI. _(Default: `true`)_
* `iriValidationStrategy`: Allows to customize the used IRI validation strategy using the `IriValidationStrategy` enumeration. _(Default: `IriValidationStrategy.Pragmatic`)_

@@ -102,0 +103,0 @@ ```javascript

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