diff --git a/frontend/server/routes/handlers/create-execution-handler.js b/frontend/server/routes/handlers/create-execution-handler.js index 43bd1320..e03272dd 100644 --- a/frontend/server/routes/handlers/create-execution-handler.js +++ b/frontend/server/routes/handlers/create-execution-handler.js @@ -104,7 +104,8 @@ async function securePipeline(req, requestContent) { "value": entry["value"], }; } else if (remote !== undefined) { - const content = await httpGetContentJsonLd(remote); + const sanitizedUrl = encodeURI(decodeURI(remote)); + const content = await httpGetContentJsonLd(sanitizedUrl); return { "contentType": CONTENT.JSONLD, "fileName": "pipeline.jsonld", diff --git a/frontend/server/routes/handlers/http-request.js b/frontend/server/routes/handlers/http-request.js index 1f0280e6..54da6184 100644 --- a/frontend/server/routes/handlers/http-request.js +++ b/frontend/server/routes/handlers/http-request.js @@ -18,7 +18,7 @@ async function httpGetContent(url, accept) { "headers": { "accept": accept, }, - "url": sanitizeUrl(url), + "url": url, }; return new Promise((resolve, reject) => { request.get(options, (error, response, body) => { @@ -31,13 +31,6 @@ async function httpGetContent(url, accept) { }); } -/** - * Required to make it work with national characters in URL. - */ -function sanitizeUrl(url) { - return encodeURI(decodeURI(url)); -} - /** * Each part must contain: value, contentType and fileName. */ @@ -56,7 +49,7 @@ function httpPostContent(url, parts, headers) { })); } const options = { - "url": sanitizeUrl(url), + "url": url, "headers": headers, "formData": formData }; @@ -65,7 +58,7 @@ function httpPostContent(url, parts, headers) { function httpGetForProxy(url, req, res, extra = {}) { const options = { - "url": sanitizeUrl(url), + "url": url, "headers": extra.headers ?? req.headers, "qs": extra.query ?? req.query, }; @@ -86,7 +79,7 @@ function handleConnectionError(url, error, res) { function httpPostForProxy(url, req, res) { const options = { - "url": sanitizeUrl(url), + "url": url, "headers": req.headers, "qs": req.query, "form": req.body, @@ -98,7 +91,7 @@ function httpPostForProxy(url, req, res) { function httpDeleteForProxy(url, req, res, extra = {}) { const options = { - "url": sanitizeUrl(url), + "url": url, "headers": extra.headers ?? req.headers, "qs": extra.query ?? req.query, }; @@ -109,7 +102,7 @@ function httpDeleteForProxy(url, req, res, extra = {}) { function httpPutContent(url, req, res, extra = {}) { const options = { - "url": sanitizeUrl(url), + "url": url, "qs": req.query, "formData": extra?.formData, }; @@ -120,7 +113,7 @@ function httpPutContent(url, req, res, extra = {}) { function httpPutForProxy(url, req, res) { const options = { - "url": sanitizeUrl(url), + "url": url, "qs": req.query, "form": req.body }; diff --git a/frontend/server/routes/handlers/import-handler.js b/frontend/server/routes/handlers/import-handler.js index 984f5869..a47e2572 100644 --- a/frontend/server/routes/handlers/import-handler.js +++ b/frontend/server/routes/handlers/import-handler.js @@ -82,8 +82,8 @@ async function secureContent(req, requestContent) { "value": entry["value"], }]; } else if (req.query["iri"] !== undefined) { - const url = req.query["iri"]; - const content = await httpGetContentJsonLd(url); + const sanitizedUrl = encodeURI(decodeURI(req.query["iri"])); + const content = await httpGetContentJsonLd(sanitizedUrl); return [{ "contentType": CONTENT.JSONLD, "fileName": "content.jsonld", diff --git a/frontend/server/routes/handlers/localize-handler.js b/frontend/server/routes/handlers/localize-handler.js index 56478069..351f2381 100644 --- a/frontend/server/routes/handlers/localize-handler.js +++ b/frontend/server/routes/handlers/localize-handler.js @@ -26,8 +26,8 @@ async function handleLocalize(req, res) { } const url = STORAGE_API_URL + "/management/localize"; const parts = { - "options": options, - "content": content, + "options": [options], + "content": [content], }; const headers = { "accept": req.headers["accept"] ?? CONTENT.JSONLD, @@ -81,8 +81,8 @@ async function secureContent(req, requestContent) { "value": entry["value"], }; } else if (req.query["iri"] !== undefined) { - const url = req.query["iri"]; - const content = await httpGetContentJsonLd(url); + const sanitizedUrl = encodeURI(decodeURI(req.query["iri"])); + const content = await httpGetContentJsonLd(sanitizedUrl); return { "contentType": CONTENT.JSONLD, "fileName": "content.jsonld",