linkeddata / rdflib.js

Linked Data API for JavaScript
http://linkeddata.github.io/rdflib.js/doc/
Other
566 stars 143 forks source link

Periods in abbreviated Turtle URIs cause EOF when parsed #622

Closed dbrnz closed 10 months ago

dbrnz commented 1 year ago

The following Turtle:

@prefix : <#> .
:test.1 a <#Test> .

validates as correct using https://www.w3.org/2015/03/ShExValidata/ yet parsing it with rdflib.js produces Bad syntax: EOF found in middle of path syntax:

$rdf = require('rdflib');

const kb = $rdf.graph();

const ttl = `@prefix : <#> .
:test.1 a <#Test> .
`;

$rdf.parse(ttl, kb, 'http://example.org/test', 'text/turtle');
$ node rdftest.js
/tmp/node_modules/rdflib/lib/parse.js:111
        throw e2;
        ^

Error: SyntaxError: Line 2 of <http://example.org/test>: Bad syntax: EOF found in middle of path syntax
at: "" while trying to parse <http://example.org/test> as text/turtle
    at executeErrorCallback (/tmp/node_modules/rdflib/lib/parse.js:108:18)
    at Object.parse (/tmp/node_modules/rdflib/lib/parse.js:76:5)
    at Object.<anonymous> (/tmp/rdftest.js:9:6)
    at Module._compile (node:internal/modules/cjs/loader:1275:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
    at Module.load (node:internal/modules/cjs/loader:1133:32)
    at Module._load (node:internal/modules/cjs/loader:972:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  cause: SyntaxError: Line 2 of <http://example.org/test>: Bad syntax: EOF found in middle of path syntax
  at: ""
      at BadSyntax (/tmp/node_modules/rdflib/lib/n3parser.js:1531:11)
      at SinkParser.path (/tmp/node_modules/rdflib/lib/n3parser.js:648:17)
      at SinkParser.item (/tmp/node_modules/rdflib/lib/n3parser.js:618:19)
      at SinkParser.subject (/tmp/node_modules/rdflib/lib/n3parser.js:531:19)
      at SinkParser.object (/tmp/node_modules/rdflib/lib/n3parser.js:1268:20)
      at SinkParser.statement (/tmp/node_modules/rdflib/lib/n3parser.js:518:20)
      at SinkParser.directiveOrStatement (/tmp/node_modules/rdflib/lib/n3parser.js:341:20)
      at SinkParser.feed (/tmp/node_modules/rdflib/lib/n3parser.js:324:22)
      at SinkParser.loadBuf (/tmp/node_modules/rdflib/lib/n3parser.js:303:12)
      at Object.parse (/tmp/node_modules/rdflib/lib/parse.js:42:9) {
    lineNo: 2,
    characterInFile: -1,
    syntaxProblem: 'EOF found in middle of path syntax'
  }
}

Node.js v19.8.1
dbrnz commented 10 months ago

Closing as this appears to be covered by #601.