Skip to content

Commit

Permalink
Merge pull request #1792 from galaxian85/bugfix/potential-xss-vulnera…
Browse files Browse the repository at this point in the history
…bility
  • Loading branch information
jackycute authored Jan 13, 2023
2 parents 8b29d05 + 9df1c34 commit 30fe18d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion public/js/extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,19 @@ export function finishView (view) {
imgPlayiframe(this, '//player.vimeo.com/video/')
})
.each((key, value) => {
jsonp(`//vimeo.com/api/v2/video/${$(value).attr('data-videoid')}.json`, function (data) {
const videoId = $(value).attr('data-videoid')
let urlForJsonp = ''
try {
const url = new URL(`https://vimeo.com/api/v2/video/${videoId}.json`)
if (!url.pathname.startsWith('/api/v2/video/')) {
throw new Error(`Invalid vimeo video id: ${videoId}`)
}
urlForJsonp = `//${url.origin}${url.pathname}`
} catch (err) {
console.error(err)
return
}
jsonp(urlForJsonp, function (data) {
const thumbnailSrc = data[0].thumbnail_large
const image = `<img src="${thumbnailSrc}" />`
$(value).prepend(image)
Expand Down

0 comments on commit 30fe18d

Please sign in to comment.