@lblod/graph-rdfa-processor 2.1.6 → 2.1.7

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.
@@ -544,21 +544,21 @@ function () {
544
544
  }
545
545
  }
546
546
 
547
- s += '"""' + value.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"""/g, '\\"\\"\\"') + '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>';
547
+ s += '"""' + value.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/\\\\\\/g, "\\\\\\\\\\\\").replace(/"""/g, '\\"\\"\\"') + '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>';
548
548
  } else if (this.objects[i].type == "http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML") {
549
549
  // We can use innerHTML as a shortcut from the parentNode if the list is not empty
550
550
  if (this.objects[i].value.length == 0) {
551
551
  s += '""""""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>';
552
552
  } else {
553
- s += '"""' + this.objects[i].value[0].parentNode.innerHTML.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"""/g, '\\"\\"\\"') + '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>';
553
+ s += '"""' + this.objects[i].value[0].parentNode.innerHTML.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/\\\\\\/g, "\\\\\\\\\\\\").replace(/"""/g, '\\"\\"\\"') + '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>';
554
554
  }
555
555
  } else {
556
556
  var l = this.objects[i].value.toString();
557
557
 
558
558
  if (l.indexOf("\n") >= 0 || l.indexOf("\r") >= 0) {
559
- s += '"""' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') + '"""';
559
+ s += '"""' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/\\\\\\/g, "\\\\\\\\\\\\").replace(/"/g, '\\"') + '"""';
560
560
  } else {
561
- s += '"' + l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') + '"';
561
+ s += '"' + l.replace(/\\\\\\/g, "\\\\\\\\\\\\").replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/\\\\\\/g, "\\\\\\\\\\\\").replace(/"/g, '\\"') + '"';
562
562
  }
563
563
 
564
564
  if (this.objects[i].type != "http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/graph-rdfa-processor",
3
- "version": "2.1.6",
3
+ "version": "2.1.7",
4
4
  "description": "Green turtle GraphRdfaProcessor extracted and available as a commonJS module",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/rdfa-graph.js CHANGED
@@ -461,6 +461,7 @@ export class RDFaPredicate {
461
461
  '"""' +
462
462
  value
463
463
  .replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\")
464
+ .replace(/\\\\\\/g, "\\\\\\\\\\\\")
464
465
  .replace(/"""/g, '\\"\\"\\"') +
465
466
  '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>';
466
467
  } else if (
@@ -475,6 +476,7 @@ export class RDFaPredicate {
475
476
  '"""' +
476
477
  this.objects[i].value[0].parentNode.innerHTML
477
478
  .replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\")
479
+ .replace(/\\\\\\/g, "\\\\\\\\\\\\")
478
480
  .replace(/"""/g, '\\"\\"\\"') +
479
481
  '"""^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#HTML>';
480
482
  }
@@ -484,12 +486,19 @@ export class RDFaPredicate {
484
486
  if (l.indexOf("\n") >= 0 || l.indexOf("\r") >= 0) {
485
487
  s +=
486
488
  '"""' +
487
- l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') +
489
+ l
490
+ .replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\")
491
+ .replace(/\\\\\\/g, "\\\\\\\\\\\\")
492
+ .replace(/"/g, '\\"') +
488
493
  '"""';
489
494
  } else {
490
495
  s +=
491
496
  '"' +
492
- l.replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\").replace(/"/g, '\\"') +
497
+ l
498
+ .replace(/\\\\\\/g, "\\\\\\\\\\\\")
499
+ .replace(/([^\\]|^)(\\)(?!\\)/g, "$1\\\\")
500
+ .replace(/\\\\\\/g, "\\\\\\\\\\\\")
501
+ .replace(/"/g, '\\"') +
493
502
  '"';
494
503
  }
495
504
  if (
package/test/test.js CHANGED
@@ -24,7 +24,7 @@ describe("getRDFaGraph", function() {
24
24
  });
25
25
 
26
26
  it.only("whatever", () => {
27
- let ht = readFileSync("./bug6.html");
27
+ let ht = readFileSync("./bug7.html");
28
28
  let { document } = jsdom(ht).defaultView.window;
29
29
 
30
30
  let graph = getRDFaGraph(document, {