sanitize href

pull/220/head^2
Pete Matsyburka 2 years ago
parent 849289287e
commit 2ce57df485

@ -16,7 +16,8 @@
<div class="space-y-3 mt-5"> <div class="space-y-3 mt-5">
<a <a
v-if="completedButton.url" v-if="completedButton.url"
:href="completedButton.url" :href="sanitizeHref(completedButton.url)"
rel="noopener noreferrer nofollow"
class="white-button flex items-center w-full" class="white-button flex items-center w-full"
> >
<span> <span>
@ -215,6 +216,11 @@ export default {
this.isDownloading = false this.isDownloading = false
}, },
sanitizeHref (href) {
if (href && href.trim().match(/^((?:https?:\/\/)|\/)/)) {
return href.replace(/javascript:/g, '')
}
},
downloadSafariIos (urls) { downloadSafariIos (urls) {
const fileRequests = urls.map((url) => { const fileRequests = urls.map((url) => {
return fetch(url).then(async (resp) => { return fetch(url).then(async (resp) => {

@ -6,7 +6,7 @@
> >
<a <a
v-if="item.startsWith('<a') && item.endsWith('</a>')" v-if="item.startsWith('<a') && item.endsWith('</a>')"
:href="extractAttr(item, 'href')" :href="sanitizeHref(extractAttr(item, 'href'))"
rel="noopener noreferrer nofollow" rel="noopener noreferrer nofollow"
:class="extractAttr(item, 'class') || 'link'" :class="extractAttr(item, 'class') || 'link'"
target="_blank" target="_blank"
@ -55,6 +55,11 @@ export default {
} }
}, },
methods: { methods: {
sanitizeHref (href) {
if (href && href.trim().match(/^((?:https?:\/\/)|\/)/)) {
return href.replace(/javascript:/g, '')
}
},
extractAttr (text, attr) { extractAttr (text, attr) {
if (text.includes(attr)) { if (text.includes(attr)) {
return text.split(attr).pop().split('"')[1] return text.split(attr).pop().split('"')[1]

Loading…
Cancel
Save