Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add offensive test for video filename check

Chocobozzzcc13efbf925f
diff --git a/packages/server-commands/src/videos/videos-command.ts b/packages/server-commands/src/videos/videos-command.ts
index 58e714d467..9f5a0a03ab 100644
--- a/packages/server-commands/src/videos/videos-command.ts
+++ b/packages/server-commands/src/videos/videos-command.ts
@@ -426,7 +426,7 @@ export class VideosCommand extends AbstractCommand {
// ---------------------------------------------------------------------------
async upload (options: OverrideCommandOptions & {
- attributes?: VideoEdit
+ attributes?: VideoEdit & { filename?: string }
mode?: 'legacy' | 'resumable' // default legacy
waitTorrentGeneration?: boolean // default true
completedExpectedStatus?: HttpStatusCodeType
diff --git a/packages/tests/src/api/check-params/videos.ts b/packages/tests/src/api/check-params/videos.ts
index 7f6e36692f..998e8572c4 100644
--- a/packages/tests/src/api/check-params/videos.ts
+++ b/packages/tests/src/api/check-params/videos.ts
@@ -18,9 +18,11 @@ import {
makeDeleteRequest,
makeGetRequest,
makePutBodyRequest,
+ makeRawRequest,
makeUploadRequest,
setAccessTokensToServers,
- setDefaultVideoChannel
+ setDefaultVideoChannel,
+ waitJobs
} from '@peertube/peertube-server-commands'
import { checkBadCountPagination, checkBadSort, checkBadStartPagination } from '@tests/shared/checks.js'
import { checkUploadVideoParam } from '@tests/shared/videos.js'
@@ -593,6 +595,22 @@ describe('Test videos API validator', function () {
expectedStatus: HttpStatusCode.OK_200
})
}
+
+ {
+ const attaches = baseCorrectAttaches
+
+ const { uuid } = await checkUploadVideoParam({
+ ...baseOptions(),
+
+ attributes: { ...fields, ...attaches, filename: '../'.repeat(20) + 'toto.mp4' },
+ expectedStatus: HttpStatusCode.OK_200
+ })
+
+ await waitJobs([ server ])
+
+ const video = await server.videos.get({ id: uuid })
+ await makeRawRequest({ url: video.files[0].fileUrl, expectedStatus: HttpStatusCode.OK_200 })
+ }
})
}
@@ -940,7 +958,7 @@ describe('Test videos API validator', function () {
})
expect(res.body.data).to.be.an('array')
- expect(res.body.data.length).to.equal(7)
+ expect(res.body.data.length).to.equal(9)
})
it('Should fail without a correct uuid', async function () {
diff --git a/packages/tests/src/shared/videos.ts b/packages/tests/src/shared/videos.ts
index 1cdbae2fb9..74d622abfd 100644
--- a/packages/tests/src/shared/videos.ts
+++ b/packages/tests/src/shared/videos.ts
@@ -360,7 +360,7 @@ export async function saveVideoInServers (servers: PeerTubeServer[], uuid: strin
export function checkUploadVideoParam (options: {
server: PeerTubeServer
token: string
- attributes: Partial<VideoEdit>
+ attributes: Partial<VideoEdit> & { filename?: string }
expectedStatus?: HttpStatusCodeType
completedExpectedStatus?: HttpStatusCodeType
mode?: 'legacy' | 'resumable'