@lde/sparql-qlever 0.14.4 → 0.14.5

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.
Files changed (2) hide show
  1. package/dist/importer.js +17 -3
  2. package/package.json +2 -2
package/dist/importer.js CHANGED
@@ -168,12 +168,26 @@ export class Importer {
168
168
  const metadataFile = `${this.options.indexName}.meta-data.json`;
169
169
  const localName = basename(file);
170
170
  const decompressCommand = localName.toLowerCase().endsWith('.zip')
171
- ? `unzip -p '${localName}'`
172
- : `(gunzip -c '${localName}' 2>/dev/null || cat '${localName}')`;
173
- const indexTask = await this.options.taskRunner.run(`${decompressCommand} | qlever-index ${flags} && cat ${metadataFile}`);
171
+ ? `unzip -p ${shellQuote(localName)}`
172
+ : `(gunzip -c ${shellQuote(localName)} 2>/dev/null || cat ${shellQuote(localName)})`;
173
+ const indexTask = await this.options.taskRunner.run(`${decompressCommand} | qlever-index ${flags} && cat ${shellQuote(metadataFile)}`);
174
174
  return await this.options.taskRunner.wait(indexTask);
175
175
  }
176
176
  }
177
+ /**
178
+ * POSIX-quote a value for safe interpolation into a shell command: wrap it in
179
+ * single quotes and escape any embedded single quote as `'\''`.
180
+ *
181
+ * Without this, a data filename containing an apostrophe — e.g. a dataset
182
+ * titled `'s-Hertogenbosch`, whose distribution URL maps to a local file like
183
+ * `…Erfgoed+'s-Hertogenbosch.nt` — would terminate the surrounding quotes, so
184
+ * `cat`/`gunzip` would read a non-existent path and feed `qlever-index` empty
185
+ * input. The index then "succeeds" with 0 triples, the import is treated as
186
+ * failed, and every distribution (and the JSON-LD fallback) fails the same way.
187
+ */
188
+ function shellQuote(value) {
189
+ return `'${value.replace(/'/g, "'\\''")}'`;
190
+ }
177
191
  /**
178
192
  * Native QLever index formats — `qlever-index -F <flag>` consumes these
179
193
  * directly. JSON-LD is not here: it is preprocessed to N-Quads first (see
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/sparql-qlever",
3
- "version": "0.14.4",
3
+ "version": "0.14.5",
4
4
  "repository": {
5
5
  "url": "git+https://github.com/ldelements/lde.git",
6
6
  "directory": "packages/sparql-qlever"
@@ -35,7 +35,7 @@
35
35
  "rdf-parse": "^5.0.0",
36
36
  "rdf-serialize": "^5.1.0",
37
37
  "tslib": "^2.3.0",
38
- "yauzl": "^3.2.0"
38
+ "yauzl": "^3.3.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@rdfjs/types": "^2.0.0",