From 19baaa994b3fe2dbc8c1944b1ec5e23e0572a14e Mon Sep 17 00:00:00 2001 From: Eric Jinks Date: Fri, 16 Feb 2018 16:06:21 +1000 Subject: [PATCH] Sanitize github svg download_url --- src/util/fetch-content.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util/fetch-content.js b/src/util/fetch-content.js index 478842a..03e3cf9 100644 --- a/src/util/fetch-content.js +++ b/src/util/fetch-content.js @@ -34,7 +34,11 @@ const parseYaml = data => { const replaceUploadUrls = (uploads = [], string) => { uploads.forEach(upload => { - string = string.replace(upload.publicPath, upload.download_url) + const url = new URL(upload.download_url) + if (url.pathname.match(/.svg$/)) { + url.search += (url.search.slice(1) === '' ? '?' : '&') + 'sanitize=true' + } + string = string.replace(upload.publicPath, url) }) return string }