From 706c6d46da9fb61491cf20f3313091b85dbf648f Mon Sep 17 00:00:00 2001 From: Emma Date: Tue, 1 Aug 2023 18:35:06 -0400 Subject: [PATCH] Fix bug with wsrv (#1239) * Fix bug with wsrv * Address comment --- helpers/parse.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/helpers/parse.js b/helpers/parse.js index a6f84cc9..cc098bd9 100644 --- a/helpers/parse.js +++ b/helpers/parse.js @@ -68,6 +68,10 @@ export const configuredXss = new xss.FilterXSS({ try { const url = new URL(value) + if (url.hostname.includes('wsrv.nl')) { + url.searchParams.delete('errorredirect') + } + const allowedHostnames = [ 'imgur.com', 'i.imgur.com', @@ -88,9 +92,11 @@ export const configuredXss = new xss.FilterXSS({ return xss.safeAttrValue( tag, name, - `https://wsrv.nl/?url=${encodeURIComponent(value)}&n=-1`, + `https://wsrv.nl/?url=${encodeURIComponent(url.toString())}&n=-1`, cssFilter ) + } else { + return xss.safeAttrValue(tag, name, url.toString(), cssFilter) } } catch (err) {} }