Fix bug with wsrv (#1239)

* Fix bug with wsrv

* Address comment
This commit is contained in:
Emma
2023-08-01 18:35:06 -04:00
committed by GitHub
parent 04915cc65a
commit 706c6d46da

View File

@@ -68,6 +68,10 @@ export const configuredXss = new xss.FilterXSS({
try { try {
const url = new URL(value) const url = new URL(value)
if (url.hostname.includes('wsrv.nl')) {
url.searchParams.delete('errorredirect')
}
const allowedHostnames = [ const allowedHostnames = [
'imgur.com', 'imgur.com',
'i.imgur.com', 'i.imgur.com',
@@ -88,9 +92,11 @@ export const configuredXss = new xss.FilterXSS({
return xss.safeAttrValue( return xss.safeAttrValue(
tag, tag,
name, name,
`https://wsrv.nl/?url=${encodeURIComponent(value)}&n=-1`, `https://wsrv.nl/?url=${encodeURIComponent(url.toString())}&n=-1`,
cssFilter cssFilter
) )
} else {
return xss.safeAttrValue(tag, name, url.toString(), cssFilter)
} }
} catch (err) {} } catch (err) {}
} }