rdf-canonize
rdf-canonize copied to clipboard
Escape IRIs
In lib/NQuads.js
, string literals are escaped. But IRIs are not.
RDF 1.1 N-Quads includes this production:
[10] IRIREF::='<' ([^#x00-#x20<>"{}|^`\] | UCHAR)* '>'
Here is a test showing a statement with a IRI that does not match the IRIREF production, which is parsed without error and serialized without escaping.
const assert = require('assert');
const canonize = require('.');
const NQuads = require('./lib/NQuads');
function assertIsCanonical(line) {
var stmt = NQuads.parse(line)[0]
var out = NQuads.serializeQuad(stmt);
assert.equal(line, out);
}
// this should fail, but it currently passes:
assertIsCanonical('<urn:ex:s"{}\t|^`\\> <urn:ex:016> "asdf" .\n')
I also opened an issue about this on the test suite: https://github.com/json-ld/normalization/issues/15