Skip to content

Commit 30fe18d

Browse files
authored
Merge pull request #1792 from galaxian85/bugfix/potential-xss-vulnerability
2 parents 8b29d05 + 9df1c34 commit 30fe18d

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

public/js/extra.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,19 @@ export function finishView (view) {
320320
imgPlayiframe(this, '//player.vimeo.com/video/')
321321
})
322322
.each((key, value) => {
323-
jsonp(`//vimeo.com/api/v2/video/${$(value).attr('data-videoid')}.json`, function (data) {
323+
const videoId = $(value).attr('data-videoid')
324+
let urlForJsonp = ''
325+
try {
326+
const url = new URL(`https://vimeo.com/api/v2/video/${videoId}.json`)
327+
if (!url.pathname.startsWith('/api/v2/video/')) {
328+
throw new Error(`Invalid vimeo video id: ${videoId}`)
329+
}
330+
urlForJsonp = `//${url.origin}${url.pathname}`
331+
} catch (err) {
332+
console.error(err)
333+
return
334+
}
335+
jsonp(urlForJsonp, function (data) {
324336
const thumbnailSrc = data[0].thumbnail_large
325337
const image = `<img src="${thumbnailSrc}" />`
326338
$(value).prepend(image)

0 commit comments

Comments
 (0)