aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-11 14:57:53 +0200
committerChocobozzz <me@florianbigard.com>2021-10-11 14:57:53 +0200
commite5d9877f0640e72653f6d88c743ee331dba6dc5b (patch)
tree062f309fd3a86988dc61aeb7836627d16112f236
parentc55d76206cd462bad7eadd0c96f1ef5b3c629f9f (diff)
downloadPeerTube-e5d9877f0640e72653f6d88c743ee331dba6dc5b.tar.gz
PeerTube-e5d9877f0640e72653f6d88c743ee331dba6dc5b.tar.zst
PeerTube-e5d9877f0640e72653f6d88c743ee331dba6dc5b.zip
Simpler ID match
-rw-r--r--server/middlewares/validators/oembed.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/server/middlewares/validators/oembed.ts b/server/middlewares/validators/oembed.ts
index cbd645a71..32dd05271 100644
--- a/server/middlewares/validators/oembed.ts
+++ b/server/middlewares/validators/oembed.ts
@@ -28,7 +28,6 @@ function buildUrls (paths: string[]) {
28const startPlaylistURLs = buildUrls(playlistPaths) 28const startPlaylistURLs = buildUrls(playlistPaths)
29const startVideoURLs = buildUrls(videoPaths) 29const startVideoURLs = buildUrls(videoPaths)
30 30
31const watchRegex = /\/([^/]+)$/
32const isURLOptions = { 31const isURLOptions = {
33 require_host: true, 32 require_host: true,
34 require_tld: true 33 require_tld: true
@@ -81,9 +80,9 @@ const oembedValidator = [
81 80
82 const startIsOk = isVideo || isPlaylist 81 const startIsOk = isVideo || isPlaylist
83 82
84 const matches = watchRegex.exec(urlPath) 83 const parts = urlPath.split('/')
85 84
86 if (startIsOk === false || matches === null) { 85 if (startIsOk === false || parts.length === 0) {
87 return res.fail({ 86 return res.fail({
88 status: HttpStatusCode.BAD_REQUEST_400, 87 status: HttpStatusCode.BAD_REQUEST_400,
89 message: 'Invalid url.', 88 message: 'Invalid url.',
@@ -93,7 +92,7 @@ const oembedValidator = [
93 }) 92 })
94 } 93 }
95 94
96 const elementId = toCompleteUUID(matches[1]) 95 const elementId = toCompleteUUID(parts.pop())
97 if (isIdOrUUIDValid(elementId) === false) { 96 if (isIdOrUUIDValid(elementId) === false) {
98 return res.fail({ message: 'Invalid video or playlist id.' }) 97 return res.fail({ message: 'Invalid video or playlist id.' })
99 } 98 }