From 65b04bbff7153d601c8b7de625d27cfc4365d336 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 30 Jan 2024 13:33:49 +0100 Subject: [PATCH] Check untranslatable requested type for RDF --- lib/handlers/get.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/handlers/get.js b/lib/handlers/get.js index f4350f70..dd46461a 100644 --- a/lib/handlers/get.js +++ b/lib/handlers/get.js @@ -116,10 +116,9 @@ async function handler (req, res, next) { // If it is not in our RDFs we can't even translate, // Sorry, we can't help - if (!possibleRDFType) { - return next(error(406, 'Cannot serve requested type: ' + contentType)) + if (!possibleRDFType || !RDFs.includes(requestedType)) { + return next(error(406, 'Cannot serve requested type: ' + requestedType)) } - try { // Translate from the contentType found to the possibleRDFType desired const data = await translate(stream, baseUri, contentType, possibleRDFType) @@ -127,7 +126,8 @@ async function handler (req, res, next) { res.setHeader('Content-Type', possibleRDFType) res.send(data) return next() - } catch (err) { + } + catch (err) { debug('error translating: ' + req.originalUrl + ' ' + contentType + ' -> ' + possibleRDFType + ' -- ' + 406 + ' ' + err.message) return next(error(406, 'Cannot serve requested type: ' + requestedType)) }