diff options
Diffstat (limited to 'server/lib/client-html.ts')
-rw-r--r-- | server/lib/client-html.ts | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index f19ec7df0..203bd3893 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -5,12 +5,13 @@ import validator from 'validator' | |||
5 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' | 5 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n' |
6 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' | 6 | import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' |
7 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' | 7 | import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos' |
8 | import { escapeHTML, isTestInstance, sha256 } from '../helpers/core-utils' | 8 | import { isTestInstance, sha256 } from '../helpers/core-utils' |
9 | import { escapeHTML } from '@shared/core-utils/renderer' | ||
9 | import { logger } from '../helpers/logger' | 10 | import { logger } from '../helpers/logger' |
10 | import { CONFIG } from '../initializers/config' | 11 | import { CONFIG } from '../initializers/config' |
11 | import { | 12 | import { |
12 | ACCEPT_HEADERS, | 13 | ACCEPT_HEADERS, |
13 | AVATARS_SIZE, | 14 | ACTOR_IMAGES_SIZE, |
14 | CUSTOM_HTML_TAG_COMMENTS, | 15 | CUSTOM_HTML_TAG_COMMENTS, |
15 | EMBED_SIZE, | 16 | EMBED_SIZE, |
16 | FILES_CONTENT_HASH, | 17 | FILES_CONTENT_HASH, |
@@ -23,6 +24,7 @@ import { VideoChannelModel } from '../models/video/video-channel' | |||
23 | import { getActivityStreamDuration } from '../models/video/video-format-utils' | 24 | import { getActivityStreamDuration } from '../models/video/video-format-utils' |
24 | import { VideoPlaylistModel } from '../models/video/video-playlist' | 25 | import { VideoPlaylistModel } from '../models/video/video-playlist' |
25 | import { MAccountActor, MChannelActor } from '../types/models' | 26 | import { MAccountActor, MChannelActor } from '../types/models' |
27 | import { mdToPlainText } from '../helpers/markdown' | ||
26 | 28 | ||
27 | type Tags = { | 29 | type Tags = { |
28 | ogType: string | 30 | ogType: string |
@@ -93,13 +95,13 @@ class ClientHtml { | |||
93 | } | 95 | } |
94 | 96 | ||
95 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) | 97 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(video.name)) |
96 | customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(video.description)) | 98 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(video.description)) |
97 | 99 | ||
98 | const url = WEBSERVER.URL + video.getWatchStaticPath() | 100 | const url = WEBSERVER.URL + video.getWatchStaticPath() |
99 | const originUrl = video.url | 101 | const originUrl = video.url |
100 | const title = escapeHTML(video.name) | 102 | const title = escapeHTML(video.name) |
101 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 103 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
102 | const description = escapeHTML(video.description) | 104 | const description = mdToPlainText(video.description) |
103 | 105 | ||
104 | const image = { | 106 | const image = { |
105 | url: WEBSERVER.URL + video.getPreviewStaticPath() | 107 | url: WEBSERVER.URL + video.getPreviewStaticPath() |
@@ -151,13 +153,13 @@ class ClientHtml { | |||
151 | } | 153 | } |
152 | 154 | ||
153 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) | 155 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(videoPlaylist.name)) |
154 | customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(videoPlaylist.description)) | 156 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(videoPlaylist.description)) |
155 | 157 | ||
156 | const url = videoPlaylist.getWatchUrl() | 158 | const url = videoPlaylist.getWatchUrl() |
157 | const originUrl = videoPlaylist.url | 159 | const originUrl = videoPlaylist.url |
158 | const title = escapeHTML(videoPlaylist.name) | 160 | const title = escapeHTML(videoPlaylist.name) |
159 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 161 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
160 | const description = escapeHTML(videoPlaylist.description) | 162 | const description = mdToPlainText(videoPlaylist.description) |
161 | 163 | ||
162 | const image = { | 164 | const image = { |
163 | url: videoPlaylist.getThumbnailUrl() | 165 | url: videoPlaylist.getThumbnailUrl() |
@@ -235,18 +237,18 @@ class ClientHtml { | |||
235 | } | 237 | } |
236 | 238 | ||
237 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) | 239 | let customHtml = ClientHtml.addTitleTag(html, escapeHTML(entity.getDisplayName())) |
238 | customHtml = ClientHtml.addDescriptionTag(customHtml, escapeHTML(entity.description)) | 240 | customHtml = ClientHtml.addDescriptionTag(customHtml, mdToPlainText(entity.description)) |
239 | 241 | ||
240 | const url = entity.getLocalUrl() | 242 | const url = entity.getLocalUrl() |
241 | const originUrl = entity.Actor.url | 243 | const originUrl = entity.Actor.url |
242 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) | 244 | const siteName = escapeHTML(CONFIG.INSTANCE.NAME) |
243 | const title = escapeHTML(entity.getDisplayName()) | 245 | const title = escapeHTML(entity.getDisplayName()) |
244 | const description = escapeHTML(entity.description) | 246 | const description = mdToPlainText(entity.description) |
245 | 247 | ||
246 | const image = { | 248 | const image = { |
247 | url: entity.Actor.getAvatarUrl(), | 249 | url: entity.Actor.getAvatarUrl(), |
248 | width: AVATARS_SIZE.width, | 250 | width: ACTOR_IMAGES_SIZE.AVATARS.width, |
249 | height: AVATARS_SIZE.height | 251 | height: ACTOR_IMAGES_SIZE.AVATARS.height |
250 | } | 252 | } |
251 | 253 | ||
252 | const ogType = 'website' | 254 | const ogType = 'website' |
@@ -377,7 +379,7 @@ class ClientHtml { | |||
377 | } | 379 | } |
378 | 380 | ||
379 | metaTags['og:url'] = tags.url | 381 | metaTags['og:url'] = tags.url |
380 | metaTags['og:description'] = tags.description | 382 | metaTags['og:description'] = mdToPlainText(tags.description) |
381 | 383 | ||
382 | if (tags.embed) { | 384 | if (tags.embed) { |
383 | metaTags['og:video:url'] = tags.embed.url | 385 | metaTags['og:video:url'] = tags.embed.url |
@@ -393,7 +395,7 @@ class ClientHtml { | |||
393 | private static generateStandardMetaTags (tags: Tags) { | 395 | private static generateStandardMetaTags (tags: Tags) { |
394 | return { | 396 | return { |
395 | name: tags.title, | 397 | name: tags.title, |
396 | description: tags.description, | 398 | description: mdToPlainText(tags.description), |
397 | image: tags.image.url | 399 | image: tags.image.url |
398 | } | 400 | } |
399 | } | 401 | } |