aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/client-html.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/client-html.ts')
-rw-r--r--server/lib/client-html.ts17
1 files changed, 11 insertions, 6 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 6ddaa82c8..5485376d3 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -24,6 +24,7 @@ import { VideoChannelModel } from '../models/video/video-channel'
24import { getActivityStreamDuration } from '../models/video/video-format-utils' 24import { getActivityStreamDuration } from '../models/video/video-format-utils'
25import { VideoPlaylistModel } from '../models/video/video-playlist' 25import { VideoPlaylistModel } from '../models/video/video-playlist'
26import { MAccountActor, MChannelActor } from '../types/models' 26import { MAccountActor, MChannelActor } from '../types/models'
27import { toSafeHtml } from '../helpers/markdown'
27 28
28type Tags = { 29type Tags = {
29 ogType: string 30 ogType: string
@@ -54,6 +55,10 @@ type Tags = {
54 } 55 }
55} 56}
56 57
58const toPlainText = (content: string) => {
59 return toSafeHtml(content).replace(/<[^>]+>/g, '')
60}
61
57class ClientHtml { 62class ClientHtml {
58 63
59 private static htmlCache: { [path: string]: string } = {} 64 private static htmlCache: { [path: string]: string } = {}
@@ -94,13 +99,13 @@ class ClientHtml {
94 } 99 }
95 100
96 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) 101 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name))
97 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description)) 102 customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(video.description))
98 103
99 const url = WEBSERVER.URL + video.getWatchStaticPath() 104 const url = WEBSERVER.URL + video.getWatchStaticPath()
100 const originUrl = video.url 105 const originUrl = video.url
101 const title = escapeHTML(video.name) 106 const title = escapeHTML(video.name)
102 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 107 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
103 const description = escapeHTML(video.description) 108 const description = toPlainText(video.description)
104 109
105 const image = { 110 const image = {
106 url: WEBSERVER.URL + video.getPreviewStaticPath() 111 url: WEBSERVER.URL + video.getPreviewStaticPath()
@@ -152,13 +157,13 @@ class ClientHtml {
152 } 157 }
153 158
154 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) 159 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name))
155 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description)) 160 customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(videoPlaylist.description))
156 161
157 const url = videoPlaylist.getWatchUrl() 162 const url = videoPlaylist.getWatchUrl()
158 const originUrl = videoPlaylist.url 163 const originUrl = videoPlaylist.url
159 const title = escapeHTML(videoPlaylist.name) 164 const title = escapeHTML(videoPlaylist.name)
160 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 165 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
161 const description = escapeHTML(videoPlaylist.description) 166 const description = toPlainText(videoPlaylist.description)
162 167
163 const image = { 168 const image = {
164 url: videoPlaylist.getThumbnailUrl() 169 url: videoPlaylist.getThumbnailUrl()
@@ -236,13 +241,13 @@ class ClientHtml {
236 } 241 }
237 242
238 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) 243 let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName()))
239 customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description)) 244 customHtml = ClientHtml.addDescriptionTag(customHtml, toPlainText(entity.description))
240 245
241 const url = entity.getLocalUrl() 246 const url = entity.getLocalUrl()
242 const originUrl = entity.Actor.url 247 const originUrl = entity.Actor.url
243 const siteName = escapeHTML(CONFIG.INSTANCE.NAME) 248 const siteName = escapeHTML(CONFIG.INSTANCE.NAME)
244 const title = escapeHTML(entity.getDisplayName()) 249 const title = escapeHTML(entity.getDisplayName())
245 const description = escapeHTML(entity.description) 250 const description = toPlainText(entity.description)
246 251
247 const image = { 252 const image = {
248 url: entity.Actor.getAvatarUrl(), 253 url: entity.Actor.getAvatarUrl(),