n3 2.0.3 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/N3Lexer.js CHANGED
@@ -45,6 +45,9 @@ const escapeReplacements = {
45
45
  '%': '%'
46
46
  };
47
47
  const illegalIriChars = /[\x00-\x20<>\\"\{\}\|\^\`]/;
48
+ function isSurrogateCodePoint(charCode) {
49
+ return charCode >= 0xD800 && charCode <= 0xDFFF;
50
+ }
48
51
  const lineModeRegExps = {
49
52
  _iri: true,
50
53
  _unescapedIri: true,
@@ -414,10 +417,21 @@ class N3Lexer {
414
417
  let invalid = false;
415
418
  const replaced = item.replace(escapeSequence, (sequence, unicode4, unicode8, escapedChar) => {
416
419
  // 4-digit unicode character
417
- if (typeof unicode4 === 'string') return String.fromCharCode(Number.parseInt(unicode4, 16));
420
+ if (typeof unicode4 === 'string') {
421
+ const charCode = Number.parseInt(unicode4, 16);
422
+ if (isSurrogateCodePoint(charCode)) {
423
+ invalid = true;
424
+ return '';
425
+ }
426
+ return String.fromCharCode(charCode);
427
+ }
418
428
  // 8-digit unicode character
419
429
  if (typeof unicode8 === 'string') {
420
430
  let charCode = Number.parseInt(unicode8, 16);
431
+ if (isSurrogateCodePoint(charCode)) {
432
+ invalid = true;
433
+ return '';
434
+ }
421
435
  return charCode <= 0xFFFF ? String.fromCharCode(Number.parseInt(unicode8, 16)) : String.fromCharCode(0xD800 + ((charCode -= 0x10000) >> 10), 0xDC00 + (charCode & 0x3FF));
422
436
  }
423
437
  // fixed escape sequence
package/lib/N3Reasoner.js CHANGED
@@ -36,8 +36,6 @@ class N3Reasoner {
36
36
  this._store._addToIndex(graphItem.objects, object, subject, predicate);
37
37
  cb();
38
38
  }
39
-
40
- // eslint-disable-next-line no-warning-comments
41
39
  _evaluatePremise(rule, content, cb, i = 0) {
42
40
  let v1, v2, value, index1, index2;
43
41
  const [val0, val1, val2] = rule.premise[i].value,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n3",
3
- "version": "2.0.3",
3
+ "version": "2.1.0",
4
4
  "description": "Lightning fast, asynchronous, streaming Turtle / N3 / RDF library.",
5
5
  "author": "Ruben Verborgh <ruben.verborgh@gmail.com>",
6
6
  "keywords": [
@@ -37,20 +37,24 @@
37
37
  "browserify": "^17.0.0",
38
38
  "deep-taxonomy-benchmark": "^2.0.0",
39
39
  "docco": "^0.9.1",
40
- "eslint": "^8.57.1",
41
- "eslint-plugin-import": "^2.29.1",
42
- "eslint-plugin-jest": "^28.8.3",
43
- "jest": "^29.7.0",
44
- "pre-commit": "^1.2.2",
40
+ "esbuild": "^0.28.1",
41
+ "eslint": "^10.4.1",
42
+ "eslint-plugin-import-x": "^4.16.2",
43
+ "eslint-plugin-jest": "^29.15.0",
44
+ "globals": "^17.6.0",
45
+ "jest": "^30.4.2",
46
+ "pre-commit": "^2.0.0",
45
47
  "rdf-isomorphic": "^2.0.0",
46
- "rdf-test-suite": "^1.25.0",
48
+ "rdf-test-suite": "^2.1.4",
47
49
  "streamify-string": "^1.0.1",
48
50
  "uglify-js": "^3.14.3"
49
51
  },
50
52
  "scripts": {
51
53
  "build": "npm run build:node && npm run build:browser",
52
54
  "build:node": "babel src -d lib",
53
- "build:browser": "rm -rf browser && mkdir browser && browserify -s N3 lib/index.js | uglifyjs > browser/n3.min.js",
55
+ "build:browser": "rm -rf browser && mkdir browser && npm run build:browser:umd && npm run build:browser:esm",
56
+ "build:browser:umd": "browserify -s N3 lib/index.js | uglifyjs > browser/n3.min.js",
57
+ "build:browser:esm": "node scripts/build-esm.js",
54
58
  "test": "jest",
55
59
  "lint": "eslint src perf test spec",
56
60
  "prepare": "npm run build",
@@ -94,6 +98,10 @@
94
98
  "**/test/*-test.js"
95
99
  ],
96
100
  "collectCoverage": true,
101
+ "coveragePathIgnorePatterns": [
102
+ "/node_modules/",
103
+ "/browser/"
104
+ ],
97
105
  "coverageReporters": [
98
106
  "json-summary",
99
107
  "text",
package/src/N3Lexer.js CHANGED
@@ -15,6 +15,10 @@ const escapeReplacements = {
15
15
  };
16
16
  const illegalIriChars = /[\x00-\x20<>\\"\{\}\|\^\`]/;
17
17
 
18
+ function isSurrogateCodePoint(charCode) {
19
+ return charCode >= 0xD800 && charCode <= 0xDFFF;
20
+ }
21
+
18
22
  const lineModeRegExps = {
19
23
  _iri: true,
20
24
  _unescapedIri: true,
@@ -419,11 +423,21 @@ export default class N3Lexer {
419
423
  let invalid = false;
420
424
  const replaced = item.replace(escapeSequence, (sequence, unicode4, unicode8, escapedChar) => {
421
425
  // 4-digit unicode character
422
- if (typeof unicode4 === 'string')
423
- return String.fromCharCode(Number.parseInt(unicode4, 16));
426
+ if (typeof unicode4 === 'string') {
427
+ const charCode = Number.parseInt(unicode4, 16);
428
+ if (isSurrogateCodePoint(charCode)) {
429
+ invalid = true;
430
+ return '';
431
+ }
432
+ return String.fromCharCode(charCode);
433
+ }
424
434
  // 8-digit unicode character
425
435
  if (typeof unicode8 === 'string') {
426
436
  let charCode = Number.parseInt(unicode8, 16);
437
+ if (isSurrogateCodePoint(charCode)) {
438
+ invalid = true;
439
+ return '';
440
+ }
427
441
  return charCode <= 0xFFFF ? String.fromCharCode(Number.parseInt(unicode8, 16)) :
428
442
  String.fromCharCode(0xD800 + ((charCode -= 0x10000) >> 10), 0xDC00 + (charCode & 0x3FF));
429
443
  }
package/src/N3Reasoner.js CHANGED
@@ -26,7 +26,6 @@ export default class N3Reasoner {
26
26
  cb();
27
27
  }
28
28
 
29
- // eslint-disable-next-line no-warning-comments
30
29
  _evaluatePremise(rule, content, cb, i = 0) {
31
30
  let v1, v2, value, index1, index2;
32
31
  const [val0, val1, val2] = rule.premise[i].value, index = content[rule.premise[i].content];