baseUrl: `${environment.originServerUrl}/videos/embed/${entry.video.uuid}`,
title: false,
warningTitle: false
- })
+ }),
+ entry.video.name
)
}
? this.videoService.getVideoViewUrl(video.uuid)
: null,
embedUrl: video.embedUrl,
+ embedTitle: video.name,
isLive: video.isLive,
warningTitle: false,
startTime: abuse.video.startAt,
stopTime: abuse.video.endAt
- })
+ }),
+ abuse.video.name
)
}
baseUrl: this.video.embedUrl,
title: false,
warningTitle: false
- })
+ }),
+ this.video.name
)
)
}
const options = this.getVideoOptions(this.video.embedUrl)
const embedUrl = buildVideoLink(options)
- return buildVideoOrPlaylistEmbed(embedUrl)
+ return buildVideoOrPlaylistEmbed(embedUrl, this.video.name)
}
getPlaylistIframeCode () {
const options = this.getPlaylistOptions(this.playlist.embedUrl)
const embedUrl = buildPlaylistLink(options)
- return buildVideoOrPlaylistEmbed(embedUrl)
+ return buildVideoOrPlaylistEmbed(embedUrl, this.playlist.displayName)
}
getVideoUrl () {
videoViewUrl: string
embedUrl: string
+ embedTitle: string
isLive: boolean
PeertubePlayerManager.alreadyPlayed = true
})
- self.addContextMenu(mode, player, options.common.embedUrl)
+ self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
player.bezels()
videojs(newVideoElement, videojsOptions, function (this: videojs.Player) {
const player = this
- self.addContextMenu(mode, player, options.common.embedUrl)
+ self.addContextMenu(mode, player, options.common.embedUrl, options.common.embedTitle)
PeertubePlayerManager.onPlayerChange(player)
})
return children
}
- private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string) {
+ private static addContextMenu (mode: PlayerMode, player: videojs.Player, videoEmbedUrl: string, videoEmbedTitle: string) {
const content = [
{
label: player.localize('Copy the video URL'),
{
label: player.localize('Copy embed code'),
listener: () => {
- copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl))
+ copyToClipboard(buildVideoOrPlaylistEmbed(videoEmbedUrl, videoEmbedTitle))
}
}
]
import { VideoFile } from '@shared/models'
+import { escapeHTML } from '@shared/core-utils/renderer'
function toTitleCase (str: string) {
return str.charAt(0).toUpperCase() + str.slice(1)
return time
}
-function buildVideoOrPlaylistEmbed (embedUrl: string) {
+function buildVideoOrPlaylistEmbed (embedUrl: string, embedTitle: string) {
+ const title = escapeHTML(embedTitle)
return '<iframe width="560" height="315" ' +
'sandbox="allow-same-origin allow-scripts allow-popups" ' +
+ 'title="' + title + '" ' +
'src="' + embedUrl + '" ' +
'frameborder="0" allowfullscreen>' +
'</iframe>'
serverUrl: window.location.origin,
language: navigator.language,
- embedUrl: window.location.origin + videoInfo.embedPath
+ embedUrl: window.location.origin + videoInfo.embedPath,
+ embedTitle: videoInfo.name
},
webtorrent: {
import { asyncMiddleware, oembedValidator } from '../middlewares'
import { accountNameWithHostGetValidator } from '../middlewares/validators'
import { MChannelSummary } from '@server/types/models'
+import { escapeHTML } from '@shared/core-utils/renderer'
const servicesRouter = express.Router()
const embedUrl = webserverUrl + embedPath
let embedWidth = EMBED_SIZE.width
let embedHeight = EMBED_SIZE.height
+ const embedTitle = escapeHTML(title)
let thumbnailUrl = previewPath
? webserverUrl + previewPath
}
const html = `<iframe width="${embedWidth}" height="${embedHeight}" sandbox="allow-same-origin allow-scripts" ` +
- `src="${embedUrl}" frameborder="0" allowfullscreen></iframe>`
+ `title="${embedTitle}" src="${embedUrl}" frameborder="0" allowfullscreen></iframe>`
const json: any = {
type: 'video',
return rootPath
}
-// Thanks: https://stackoverflow.com/a/12034334
-function escapeHTML (stringParam) {
- if (!stringParam) return ''
-
- const entityMap = {
- '&': '&',
- '<': '<',
- '>': '>',
- '"': '"',
- '\'': ''',
- '/': '/',
- '`': '`',
- '=': '='
- }
-
- return String(stringParam).replace(/[&<>"'`=/]/g, s => entityMap[s])
-}
-
function pageToStartAndCount (page: number, itemsPerPage: number) {
const start = (page - 1) * itemsPerPage
objectConverter,
root,
- escapeHTML,
pageToStartAndCount,
sanitizeUrl,
sanitizeHost,
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/core-utils/i18n/i18n'
import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes'
import { VideoPlaylistPrivacy, VideoPrivacy } from '../../shared/models/videos'
-import { escapeHTML, isTestInstance, sha256 } from '../helpers/core-utils'
+import { isTestInstance, sha256 } from '../helpers/core-utils'
+import { escapeHTML } from '@shared/core-utils/renderer'
import { logger } from '../helpers/logger'
import { CONFIG } from '../initializers/config'
import {
describe('Test services', function () {
let server: ServerInfo = null
let playlistUUID: string
+ let playlistDisplayName: string
let video: Video
before(async function () {
})
playlistUUID = res.body.videoPlaylist.uuid
+ playlistDisplayName = 'The Life and Times of Scrooge McDuck'
await addVideoInPlaylist({
url: server.url,
const res = await getOEmbed(server.url, oembedUrl)
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
- `src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
+ `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
const expectedThumbnailUrl = 'http://localhost:' + server.port + video.previewPath
const res = await getOEmbed(server.url, oembedUrl)
const expectedHtml = '<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts" ' +
- `src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
+ `title="${playlistDisplayName}" src="http://localhost:${server.port}/video-playlists/embed/${playlistUUID}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
const res = await getOEmbed(server.url, oembedUrl, format, maxHeight, maxWidth)
const expectedHtml = '<iframe width="50" height="50" sandbox="allow-same-origin allow-scripts" ' +
- `src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
+ `title="${video.name}" src="http://localhost:${server.port}/videos/embed/${video.uuid}" ` +
'frameborder="0" allowfullscreen></iframe>'
expect(res.body.html).to.equal(expectedHtml)
}
}
}
+
+// Thanks: https://stackoverflow.com/a/12034334
+export function escapeHTML (stringParam: string) {
+ if (!stringParam) return ''
+
+ const entityMap = {
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ '"': '"',
+ '\'': ''',
+ '/': '/',
+ '`': '`',
+ '=': '='
+ }
+
+ return String(stringParam).replace(/[&<>"'`=/]/g, s => entityMap[s])
+}