mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-01-10 23:07:00 +00:00
feat(hyperlinking): hyperlinking URLs in the channel descriptions (#304)
* feat(hyperlinking): hyperlinking URLs in the channel descriptions * fix(hyperlinking): fixed url detection * fix(hyperlinking): purify channel descriptions to prevent XSS vulnerability
This commit is contained in:
parent
46aa2cac56
commit
9068564500
@ -4,7 +4,7 @@
|
|||||||
<div v-if="channel" v-show="!channel.error">
|
<div v-if="channel" v-show="!channel.error">
|
||||||
<h1 class="uk-text-center"><img height="48" width="48" v-bind:src="channel.avatarUrl" />{{ channel.name }}</h1>
|
<h1 class="uk-text-center"><img height="48" width="48" v-bind:src="channel.avatarUrl" />{{ channel.name }}</h1>
|
||||||
<img v-if="channel.bannerUrl" v-bind:src="channel.bannerUrl" style="width: 100%" loading="lazy" />
|
<img v-if="channel.bannerUrl" v-bind:src="channel.bannerUrl" style="width: 100%" loading="lazy" />
|
||||||
<p style="white-space: pre-wrap">{{ channel.description }}</p>
|
<p style="white-space: pre-wrap"><span v-html="purifyHTML(urlify(channel.description))"></span></p>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
v-if="authenticated"
|
v-if="authenticated"
|
||||||
|
@ -158,6 +158,13 @@ const mixin = {
|
|||||||
timeAgo(time) {
|
timeAgo(time) {
|
||||||
return timeAgo.format(time);
|
return timeAgo.format(time);
|
||||||
},
|
},
|
||||||
|
urlify(string) {
|
||||||
|
const regex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
|
||||||
|
if (!string) return '';
|
||||||
|
return string.replace(regex, (url) => {
|
||||||
|
return `<a class="uk-button uk-button-text" href="${url}" target="_blank">${url}</a>`
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
backgroundColor() {
|
backgroundColor() {
|
||||||
|
Loading…
Reference in New Issue
Block a user