Compare commits

...
13 Commits
Author SHA1 Message Date
Chocobozzz b8055f5083 Bumped to version v8.3.2 2026-10-26 13:44:35 +01:00
Chocobozzz a897e93b71 Update changelog 2026-10-26 13:44:09 +01:00
Chocobozzz 57d22d55bd Limit resource usage when generating thumbnails 2026-10-26 11:56:19 +01:00
Chocobozzz 53098d3158 Upgrade vulnerable dep 2026-10-26 11:16:56 +01:00
Chocobozzz 0eef8dc69e Crawling rates optimization 2026-10-26 11:02:33 +01:00
baptiste-bcn c42ee81ccd Fix crash when remote video has no likes/dislikes collections 2026-10-26 10:53:07 +01:00
EmilienLDN 8ea9832b1b Fix audio download with a webp thumbnail
The thumbnail added as cover of audio only downloads was copied as is
in the MP4 container, which doesn't support webp images.
Convert the cover to JPEG instead.

Fixes #7806
2026-10-26 10:48:47 +01:00
Chocobozzz c4af389451 Fix podcast:medium 2026-10-26 10:46:08 +01:00
Kahina bf69ebb958 Fix channel deletion cancel showing success message
Fixes #7818
2026-10-26 10:36:38 +01:00
CristianandChocobozzz d32eaebc8e Constrain PyAV when installing whisper-ctranslate2 (#7815)
* Constrain PyAV when installing whisper-ctranslate2

PyAV 19 (2026-09-29, Python 3.12+) removed the metadata_errors argument of
av.open(). faster-whisper 1.2.1, which whisper-ctranslate2 0.4.4 installs,
still passes it, so a freshly auto-installed engine fails every
transcription and no transcript file is written.

* Prefer upgrading to latest whisper ctranslate

---------

Co-authored-by: Chocobozzz <[email protected]>
2026-10-26 10:15:55 +01:00
Chocobozzz 67ffbb2ef8 Check AP redirected URLs 2026-10-26 10:15:55 +01:00
Chocobozzz f76fa77b65 Bump sharp and block not supported formats 2026-10-26 10:15:55 +01:00
m-altaifi 6d8a604e44 Document rates_limit enabled option in changelog
The per-section `enabled` flag added in 8.3 is user-facing configuration
and resolves #6089, but was missing from the release notes.
2026-10-12 16:08:33 +02:00
31 changed files with 802 additions and 346 deletions

No files matched your search

+18
View File
@@ -1,5 +1,22 @@
# Changelog
## v8.3.2
### SECURITY
* **critical** Upgrade vulnerable `sharp` (image processing dependency) that can lead to a RCE with a special crafted SVG file [GHSA-wq5f-xc86-pv6w](https://github.com/advisories/GHSA-wq5f-xc86-pv6w)
* **high** Fix federation vulnerability where a remote attacker could exploit the redirection of cached remote objects to impersonate actors of another instance and modify its videos federated on an instance [GHSA-5j4v-77rx-h5qg](https://github.com/Chocobozzz/PeerTube/security/advisories/GHSA-5j4v-77rx-h5qg)
### Bug Fixes
* Update whisper-ctranslate2 package to fix installation on Python 3.12+
* Fix channel deletion cancel showing success message [#7837](https://github.com/Chocobozzz/PeerTube/pull/7837)
* Fix podcast feed `podcast:medium` value with `audio` enclosure preference
* Fix audio download with a webp thumbnail [#7833](https://github.com/Chocobozzz/PeerTube/pull/7833)
* Fix crash when remote video has no likes/dislikes collections [#7836](https://github.com/Chocobozzz/PeerTube/pull/7836)
* Limit resource usage when generating thumbnails
## v8.3.1
### SECURITY
@@ -62,6 +79,7 @@
* Add explicit Redis socket configuration in `redis.socket` to provide the redis socket path
* Add `user.allow_cross_provider_auth` configuration to support multiple auth plugins for the same PeerTube user [#7655](https://github.com/Chocobozzz/PeerTube/pull/7655)
* Add opt-in configuration to automatically add the username and HTTP request id as tags in the log file: `log.tag_requests`
* Add `enabled` configuration to every `rates_limit` section, so a specific rate limiter can be disabled [#6089](https://github.com/Chocobozzz/PeerTube/issues/6089)
### Plugins/Themes/Embed API
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "peertube-client",
"version": "8.3.1",
"version": "8.3.2",
"private": true,
"license": "AGPL-3.0",
"author": {
@@ -92,7 +92,7 @@
"linkify-html": "^4.3.3",
"linkifyjs": "^4.3.3",
"lodash-es": "^4.18.1",
"markdown-it": "15.0.0",
"markdown-it": "15.0.3",
"markdown-it-emoji": "^3.1.0",
"ngx-uploadx": "^7.1.0",
"p2p-media-loader-core": "^4.0.0",
@@ -159,7 +159,7 @@ export class MyVideoChannelsComponent implements OnInit {
deleteVideoChannel (videoChannel: VideoChannel) {
this.videoChannelService.removeWithConfirmation(videoChannel)
.subscribe({
next: removed => {
next: ({ removed }) => {
if (!removed) return
this.videoChannels = this.videoChannels.filter(c => c.id !== videoChannel.id)
+4 -4
View File
@@ -1,7 +1,7 @@
{
"name": "peertube",
"description": "PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.",
"version": "8.3.1",
"version": "8.3.2",
"private": true,
"license": "AGPL-3.0",
"engines": {
@@ -95,7 +95,7 @@
"@aws-sdk/lib-storage": "^3.1131.0",
"@aws-sdk/s3-request-presigner": "^3.1131.0",
"@commander-js/extra-typings": "^15.0.0",
"@img/sharp-wasm32": "^0.35.4",
"@img/sharp-wasm32": "^0.35.5",
"@logtape/adaptor-winston": "^2.3.4",
"@misskey-dev/node-http-message-signatures": "^0.0.10",
"@node-oauth/oauth2-server": "^5.3.0",
@@ -167,7 +167,7 @@
"lodash-es": "^4.18.1",
"lru-cache": "^11.5.2",
"magnet-uri": "^7.0.10",
"markdown-it": "^15.0.0",
"markdown-it": "^15.0.3",
"markdown-it-emoji": "^3.1.0",
"maxmind": "^5.0.7",
"memoizee": "^0.4.17",
@@ -190,7 +190,7 @@
"sanitize-html": "~2.17.7",
"sequelize": "~6.37.8",
"sequelize-typescript": "^2.1.6",
"sharp": "^0.35.4",
"sharp": "^0.35.5",
"short-uuid": "^6.0.3",
"sitemap": "^9.0.1",
"socket.io": "^4.8.3",
+9 -1
View File
@@ -29,7 +29,15 @@ export class FFmpegContainer {
}
command.outputOption('-c copy')
.outputOption('-movflags frag_every_frame+empty_moov')
// The cover can be in any image format (webp etc.) but the MP4 container doesn't support all of them, so convert it to JPEG
// A cover is only added to audio inputs, so the cover is the only video stream to encode
if (coverPath) {
command.outputOption('-c:v mjpeg')
.outputOption('-q:v 2')
}
command.outputOption('-movflags frag_every_frame+empty_moov')
.outputOption('-min_frag_duration 5M') // 5 seconds
.format('mp4')
.output(output)
+10 -5
View File
@@ -33,6 +33,9 @@ export class FFmpegImage {
try {
return await this.commandWrapper.runCommand()
} catch (err) {
// Don't retry if ffmpeg has been killed (OOM killer for example), the fallback would have the same resource usage
if (err?.message?.includes('killed with signal')) throw err
this.commandWrapper.debugLog('Cannot generate thumbnail from video using seek input, fallback to no seek', { err })
this.commandWrapper.resetCommand()
@@ -55,17 +58,19 @@ export class FFmpegImage {
const { fromPath, output, framesToAnalyze, scale } = options
const command = this.commandWrapper.buildCommand(fromPath)
.videoFilter('thumbnail=' + framesToAnalyze)
.outputOption('-frames:v 1')
.outputOption('-q:v 5')
.outputOption('-abort_on empty_output')
.output(output)
.inputOption('-threads 2')
// Scale before the thumbnail filter, that buffers all analyzed frames
if (scale) {
command.videoFilter(`scale=${scale.width}x${scale.height}:force_original_aspect_ratio=decrease`)
}
return command
.videoFilter('thumbnail=' + framesToAnalyze)
.outputOption('-frames:v 1')
.outputOption('-q:v 5')
.outputOption('-abort_on empty_output')
.output(output)
}
// ---------------------------------------------------------------------------
@@ -9,22 +9,12 @@ import {
setAccessTokensToServers,
waitJobs
} from '@peertube/peertube-server-commands'
import {
activityPubContextify,
buildGlobalHTTPHeaders,
getAPPublicValue
} from '@peertube/peertube-server/core/helpers/activity-pub-utils.js'
import { buildDigest } from '@peertube/peertube-server/core/helpers/peertube-crypto.js'
import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@peertube/peertube-server/core/initializers/constants.js'
import { makePOSTAPRequest } from '@tests/shared/requests.js'
import { getAPPublicValue } from '@peertube/peertube-server/core/helpers/activity-pub-utils.js'
import { makeSignedPOSTAPRequest } from '@tests/shared/requests.js'
import { SQLCommand } from '@tests/shared/sql-command.js'
import { expect } from 'chai'
import { readJsonSync } from 'fs-extra/esm'
function fakeFilter () {
return (data: any) => Promise.resolve(data)
}
function setKeysOfServer (onServer: SQLCommand, ofServerUrl: string, publicKey: string, privateKey: string) {
const url = ofServerUrl + '/accounts/peertube'
@@ -44,14 +34,6 @@ describe('Test ActivityPub actor identity binding', function () {
const keys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/keys.json'))
function buildHttpSignature () {
return {
keyId: remoteActorUrl,
key: keys.privateKey,
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN_WITH_PAYLOAD
}
}
// Send an "Update" of the remote actor, signed by that same remote actor
async function sendActorUpdate (actorObject: any) {
const activity = {
@@ -62,16 +44,14 @@ describe('Test ActivityPub actor identity binding', function () {
object: actorObject
}
const body = await activityPubContextify(activity, 'Actor', fakeFilter())
const headers = {
...buildGlobalHTTPHeaders(body, buildDigest),
'content-type': 'application/activity+json',
'accept': ACTIVITY_PUB.ACCEPT_HEADER
}
try {
const { statusCode } = await makePOSTAPRequest(inboxUrl, body, buildHttpSignature(), headers)
const { statusCode } = await makeSignedPOSTAPRequest({
url: inboxUrl,
activity,
contextType: 'Actor',
keyId: remoteActorUrl,
privateKey: keys.privateKey
})
return { rejected: false, statusCode }
} catch (err) {
@@ -0,0 +1,131 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import { HttpStatusCode } from '@peertube/peertube-models'
import { PeerTubeServer, cleanupTests, createSingleServer, setAccessTokensToServers, waitJobs } from '@peertube/peertube-server-commands'
import { getAPPublicValue } from '@peertube/peertube-server/core/helpers/activity-pub-utils.js'
import { getPort, randomListen, terminateServer } from '@tests/shared/mock-servers/shared.js'
import { makeSignedPOSTAPRequest } from '@tests/shared/requests.js'
import { SQLCommand } from '@tests/shared/sql-command.js'
import { expect } from 'chai'
import express from 'express'
import { readJsonSync } from 'fs-extra/esm'
import { Server } from 'http'
describe('Test ActivityPub fetch redirections', function () {
let server: PeerTubeServer
let sqlCommand: SQLCommand
let originServer: Server
let attackerServer: Server
let originUrl: string
let attackerUrl: string
const keys = readJsonSync(buildAbsoluteFixturePath('./ap-json/peertube/keys.json'))
function buildActor (id: string) {
return {
type: 'Person',
id,
preferredUsername: 'redirected',
inbox: id + '/inbox',
publicKey: {
id: id + '#main-key',
owner: id,
publicKeyPem: keys.publicKey
}
}
}
async function sendActorUpdate (options: {
keyId: string
actorUrl: string
}) {
const { keyId, actorUrl } = options
const activity = {
type: 'Update',
id: actorUrl + '/updates/' + new Date().toISOString(),
actor: actorUrl,
to: [ getAPPublicValue() ],
object: buildActor(actorUrl)
}
try {
const { statusCode } = await makeSignedPOSTAPRequest({
url: server.url + '/inbox',
activity,
contextType: 'Actor',
keyId,
privateKey: keys.privateKey
})
return statusCode
} catch (err) {
return err.statusCode as number
}
}
before(async function () {
this.timeout(120000)
server = await createSingleServer(1)
await setAccessTokensToServers([ server ])
sqlCommand = new SQLCommand(server)
const app = express()
app.get('/actors/spoofed', (req, res) => {
if (req.socket.localPort === getPort(originServer)) {
return res.redirect(attackerUrl + '/actors/spoofed')
}
return res.type('application/activity+json').send(buildActor(originUrl + '/actors/spoofed'))
})
app.get('/actors/alias', (req, res) => res.redirect(originUrl + '/actors/real'))
app.get('/actors/real', (req, res) => res.type('application/activity+json').send(buildActor(originUrl + '/actors/real')))
originServer = await randomListen(app)
attackerServer = await randomListen(app)
originUrl = 'http://127.0.0.1:' + getPort(originServer)
attackerUrl = 'http://127.0.0.1:' + getPort(attackerServer)
})
it('Should not accept an actor served by another host after a redirection', async function () {
this.timeout(30000)
const actorUrl = originUrl + '/actors/spoofed'
const statusCode = await sendActorUpdate({ keyId: actorUrl, actorUrl })
expect(statusCode).to.equal(HttpStatusCode.FORBIDDEN_403)
await waitJobs([ server ])
expect(await sqlCommand.countActorsByUrl(actorUrl)).to.equal(0)
})
it('Should still follow a redirection on the same host', async function () {
this.timeout(30000)
const actorUrl = originUrl + '/actors/real'
const statusCode = await sendActorUpdate({ keyId: originUrl + '/actors/alias', actorUrl })
expect(statusCode).to.equal(HttpStatusCode.NO_CONTENT_204)
await waitJobs([ server ])
expect(await sqlCommand.countActorsByUrl(actorUrl)).to.equal(1)
})
after(async function () {
await sqlCommand.cleanup()
await terminateServer(originServer)
await terminateServer(attackerServer)
await cleanupTests([ server ])
})
})
+20 -31
View File
@@ -12,7 +12,7 @@ import {
import { buildDigest } from '@peertube/peertube-server/core/helpers/peertube-crypto.js'
import { signJsonLDObject } from '@peertube/peertube-server/core/helpers/peertube-jsonld.js'
import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@peertube/peertube-server/core/initializers/constants.js'
import { makePOSTAPRequest } from '@tests/shared/requests.js'
import { fakeContextFilter, makePOSTAPRequest, makeSignedPOSTAPRequest } from '@tests/shared/requests.js'
import { SQLCommand } from '@tests/shared/sql-command.js'
import { expect } from 'chai'
import { readJsonSync } from 'fs-extra/esm'
@@ -25,10 +25,6 @@ function signJsonLDObjectWithoutAssertion (options: Parameters<typeof signJsonLD
})
}
function fakeFilter () {
return (data: any) => Promise.resolve(data)
}
function setKeysOfServer (onServer: SQLCommand, ofServerUrl: string, publicKey: string, privateKey: string) {
const url = ofServerUrl + '/accounts/peertube'
@@ -62,7 +58,7 @@ function getAnnounceWithoutContext (server: PeerTubeServer) {
return result
}
async function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
function makeFollowRequest (to: { url: string }, by: { url: string, privateKey }) {
const follow = {
type: 'Follow',
id: by.url + '/' + new Date().getTime(),
@@ -70,20 +66,13 @@ async function makeFollowRequest (to: { url: string }, by: { url: string, privat
object: to.url
}
const body = await activityPubContextify(follow, 'Follow', fakeFilter())
const httpSignature = {
return makeSignedPOSTAPRequest({
url: to.url + '/inbox',
activity: follow,
contextType: 'Follow',
keyId: by.url,
key: by.privateKey,
headers: HTTP_SIGNATURE.HEADERS_TO_SIGN_WITH_PAYLOAD
}
const headers = {
'digest': buildDigest(body),
'content-type': 'application/activity+json',
'accept': ACTIVITY_PUB.ACCEPT_HEADER
}
return makePOSTAPRequest(to.url + '/inbox', body, httpSignature, headers)
privateKey: by.privateKey
})
}
describe('Test ActivityPub security', function () {
@@ -106,7 +95,7 @@ describe('Test ActivityPub security', function () {
byActor: signer,
data: activity,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -142,7 +131,7 @@ describe('Test ActivityPub security', function () {
describe('When checking HTTP signature', function () {
it('Should fail with an invalid digest', async function () {
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = {
Digest: buildDigest({ hello: 'coucou' })
}
@@ -156,7 +145,7 @@ describe('Test ActivityPub security', function () {
})
it('Should fail with an invalid date', async function () {
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
headers['date'] = 'Wed, 21 Oct 2015 07:28:00 GMT'
@@ -172,7 +161,7 @@ describe('Test ActivityPub security', function () {
await setKeysOfServer(sqlCommands[0], servers[1].url, invalidKeys.publicKey, invalidKeys.privateKey)
await setKeysOfServer(sqlCommands[1], servers[1].url, invalidKeys.publicKey, invalidKeys.privateKey)
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
try {
@@ -187,7 +176,7 @@ describe('Test ActivityPub security', function () {
await setKeysOfServer(sqlCommands[0], servers[1].url, keys.publicKey, keys.privateKey)
await setKeysOfServer(sqlCommands[1], servers[1].url, keys.publicKey, keys.privateKey)
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
const signatureOptions = baseHttpSignature()
@@ -210,7 +199,7 @@ describe('Test ActivityPub security', function () {
})
it('Should succeed with a valid HTTP signature draft 11 (without date but with (created))', async function () {
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
const signatureOptions = baseHttpSignature()
@@ -221,7 +210,7 @@ describe('Test ActivityPub security', function () {
})
it('Should succeed with a valid HTTP signature', async function () {
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
const { statusCode } = await makePOSTAPRequest(url, body, baseHttpSignature(), headers)
@@ -246,7 +235,7 @@ describe('Test ActivityPub security', function () {
actor: servers[1].url + '/accounts/peertube',
totalItems: items.length,
orderedItems: items
}, 'Collection', fakeFilter())
}, 'Collection', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
@@ -270,7 +259,7 @@ describe('Test ActivityPub security', function () {
await killallServers([ servers[1] ])
await servers[1].run()
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeFilter())
const body = await activityPubContextify(getAnnounceWithoutContext(servers[1]), 'Announce', fakeContextFilter())
const headers = buildGlobalHTTPHeaders(body, buildDigest)
try {
@@ -306,7 +295,7 @@ describe('Test ActivityPub security', function () {
byActor: signer,
data: body,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -332,7 +321,7 @@ describe('Test ActivityPub security', function () {
byActor: signer,
data: body,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -557,7 +546,7 @@ describe('Test ActivityPub security', function () {
byActor: signer,
data: body,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -54,6 +54,7 @@ describe('Test generate download', function () {
{
await server.config.enableTranscoding({ hls: true, webVideo: true, splitAudioAndVideo: false, resolutions })
await server.videos.quickUpload({ name: 'common-' + seed })
await server.videos.upload({ attributes: { name: 'webp-thumbnail-' + seed, thumbnailfile: 'avatar.webp' } })
await waitJobs(servers)
}
@@ -76,7 +77,7 @@ describe('Test generate download', function () {
return files.find(f => f.hasAudio === true && f.hasVideo === false)
}
async function getProbe (name: 'common' | 'splitted', filesGetter: (video: VideoDetails) => number[]) {
async function getProbe (name: 'common' | 'splitted' | 'webp-thumbnail', filesGetter: (video: VideoDetails) => number[]) {
const video = await servers[0].videos.findFull({ name: name + '-' + seed })
const body = await servers[0].videos.generateDownload({ videoId: video.id, videoFileIds: filesGetter(video) })
@@ -120,6 +121,12 @@ describe('Test generate download', function () {
checkProbe(probe, { hasAudio: true, hasVideo: false, hasImage: true, muxed: true })
})
it('Should generate an audio only file with a webp thumbnail', async function () {
const probe = await getProbe('webp-thumbnail', video => [ getAudioOnlyFile(video.files).id ])
checkProbe(probe, { hasAudio: true, hasVideo: false, hasImage: true, muxed: true })
})
it('Should generate a video only file', async function () {
const probe = await getProbe('splitted', video => [ getVideoFile(getHLS(video).files).id ])
+17
View File
@@ -194,6 +194,8 @@ describe('Test syndication feeds', () => {
await servers[0].feed.getPodcastXML({ ignoreCache: false, channelId: servers[0].store.channel.id })
)
expect(xmlDoc.rss.channel['podcast:medium']).to.equal('video')
const itemGuid = xmlDoc.rss.channel.item.guid
expect(itemGuid).to.exist
expect(itemGuid['@_isPermaLink']).to.equal(true)
@@ -450,6 +452,15 @@ describe('Test syndication feeds', () => {
const channel = xmlDoc.rss.channel
expect(channel.title).to.equal('Podcast playlist')
expect(channel['podcast:medium']).to.equal('video')
})
it('Should set podcast medium with audio enclosure preference', async function () {
const xmlDoc = parseXMLFeed(
await servers[0].feed.getPodcastXML({ ignoreCache: false, playlistId: podcastPlaylistId, enclosurePreference: 'audio' })
)
expect(xmlDoc.rss.channel['podcast:medium']).to.equal('podcast')
})
it('Should not contain private video', function () {
@@ -601,6 +612,8 @@ describe('Test syndication feeds', () => {
})
)
expect(xmlDoc.rss.channel['podcast:medium']).to.equal('video')
const enclosure = xmlDoc.rss.channel.item.enclosure
expectEndWith(enclosure['@_url'], '-720.mp4')
expect(enclosure['@_type']).to.equal('video/mp4')
@@ -615,6 +628,8 @@ describe('Test syndication feeds', () => {
})
)
expect(xmlDoc.rss.channel['podcast:medium']).to.equal('podcast')
const enclosure = xmlDoc.rss.channel.item.enclosure
expectEndWith(enclosure['@_url'], '-0.mp4')
expect(enclosure['@_type']).to.equal('audio/x-m4a')
@@ -629,6 +644,8 @@ describe('Test syndication feeds', () => {
})
)
expect(xmlDoc.rss.channel['podcast:medium']).to.equal('video')
const enclosure = xmlDoc.rss.channel.item.enclosure
expectEndWith(enclosure['@_url'], '-master.m3u8')
expect(enclosure['@_type']).to.equal('application/x-mpegURL')
@@ -4,6 +4,7 @@ import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import { signAndContextify } from '@peertube/peertube-server/core/helpers/activity-pub-utils.js'
import { isHTTPSignatureVerified, parseHTTPSignature } from '@peertube/peertube-server/core/helpers/peertube-crypto.js'
import { compactJSONLDAndCheckSignature, signJsonLDObject } from '@peertube/peertube-server/core/helpers/peertube-jsonld.js'
import { fakeContextFilter } from '@tests/shared/requests.js'
import { expect } from 'chai'
import { readJsonSync } from 'fs-extra/esm'
import cloneDeep from 'lodash-es/cloneDeep.js'
@@ -20,10 +21,6 @@ function signJsonLDObjectWithoutAssertion (options: Parameters<typeof signJsonLD
})
}
function fakeFilter () {
return (data: any) => Promise.resolve(data)
}
function fakeExpressReq (body: any) {
return { body }
}
@@ -69,7 +66,7 @@ describe('Test activity pub helpers', function () {
byActor: actorSignature as any,
data: body,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -88,7 +85,7 @@ describe('Test activity pub helpers', function () {
byActor: actorSignature as any,
data: body,
contextType: 'Announce',
contextFilter: fakeFilter(),
contextFilter: fakeContextFilter(),
signerFunction: signJsonLDObjectWithoutAssertion
})
@@ -0,0 +1,78 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions */
import { FFmpegContainer, ffprobePromise } from '@peertube/peertube-ffmpeg'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import { expect } from 'chai'
import { createWriteStream } from 'fs'
import { copy, remove } from 'fs-extra/esm'
import { mkdtemp } from 'fs/promises'
import { tmpdir } from 'os'
import { join } from 'path'
describe('FFmpeg container', function () {
let tmpDirectory: string
before(async function () {
tmpDirectory = await mkdtemp(join(tmpdir(), 'peertube-test-ffmpeg-container-'))
})
describe('Merge an audio file with a cover', function () {
async function mergeAndProbe (coverPath: string) {
const outputPath = join(tmpDirectory, 'output.mp4')
await buildFFmpegContainer().mergeInputs({
inputs: [ buildAbsoluteFixturePath('video_short_0p.mp4') ],
output: createWriteStream(outputPath),
logError: true,
coverPath
})
return ffprobePromise(outputPath)
}
async function checkAudioWithJPEGCover (coverPath: string) {
const probe = await mergeAndProbe(coverPath)
const audioStreams = probe.streams.filter(s => s.codec_type === 'audio')
expect(audioStreams).to.have.lengthOf(1)
expect(audioStreams[0].codec_name).to.equal('aac')
const videoStreams = probe.streams.filter(s => s.codec_type === 'video')
expect(videoStreams).to.have.lengthOf(1)
expect(videoStreams[0].codec_name).to.equal('mjpeg')
}
for (const coverFixture of [ 'custom-thumbnail-big.jpg', 'avatar.png', 'avatar.webp' ]) {
it(`Should embed ${coverFixture} cover as JPEG`, async function () {
this.timeout(30000)
await checkAudioWithJPEGCover(buildAbsoluteFixturePath(coverFixture))
})
}
it('Should embed a webp cover with a misleading extension as JPEG', async function () {
this.timeout(30000)
// Remote thumbnails are downloaded as is, with an extension built from the mimetype sent by the remote server
const coverPath = join(tmpDirectory, 'webp-cover.jpg')
await copy(buildAbsoluteFixturePath('avatar.webp'), coverPath)
await checkAudioWithJPEGCover(coverPath)
})
})
after(async function () {
await remove(tmpDirectory)
})
function buildFFmpegContainer () {
const noop = () => {}
return new FFmpegContainer({
niceness: 0,
threads: 1,
tmpDirectory,
logger: { info: noop, debug: noop, warn: noop, error: noop }
})
}
})
+64 -1
View File
@@ -1,8 +1,10 @@
/* oxlint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import { HttpStatusCode } from '@peertube/peertube-models'
import { buildAbsoluteFixturePath, root } from '@peertube/peertube-node-utils'
import { execPromise } from '@peertube/peertube-server/core/helpers/core-utils.js'
import { processImage, processSVG } from '@peertube/peertube-server/core/helpers/image-utils.js'
import { isDecodableImageExtension, processImage, processSVG } from '@peertube/peertube-server/core/helpers/image-utils.js'
import { CONSTRAINTS_FIELDS, MIMETYPES } from '@peertube/peertube-server/core/initializers/constants.js'
import { expect } from 'chai'
import { ensureDir, remove } from 'fs-extra/esm'
import { readFile, writeFile } from 'fs/promises'
@@ -132,6 +134,67 @@ describe('Image helpers', function () {
}
})
it('Should refuse to decode a SVG file disguised as a jpg file', async function () {
await ensureDir(imageDestDir)
const input = join(imageDestDir, 'svg-disguised-as.jpg')
await writeFile(input, '<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><rect width="10" height="10"/></svg>')
try {
await processImage({ path: input, destination: imageDestJPG, newSize: thumbnailSize, keepOriginal: true })
expect.fail('Should not decode a SVG file disguised as a jpg file')
} catch (err) {
expect(err.message).to.contain('unsupported image format')
expect(err.status).to.equal(HttpStatusCode.BAD_REQUEST_400)
} finally {
await remove(input)
}
})
it('Should process webp', async function () {
const input = buildAbsoluteFixturePath('avatar.webp')
const dest = join(imageDestDir, 'avatar.webp')
await processImage({ path: input, destination: dest, newSize: { width: 48, height: 48 }, keepOriginal: true })
const metadata = await sharp(await readFile(dest)).metadata()
expect(metadata.format).to.equal('webp')
expect(metadata.width).to.equal(48)
})
it('Should process avif and tiff', async function () {
await ensureDir(imageDestDir)
const source = buildAbsoluteFixturePath('custom-thumbnail-big.jpg')
for (const ext of [ '.avif', '.tiff' ]) {
const input = join(imageDestDir, 'source' + ext)
await sharp(source).toFile(input)
const dest = join(imageDestDir, 'from-' + ext.slice(1) + '.jpg')
await processImage({ path: input, destination: dest, newSize: thumbnailSize, keepOriginal: true })
const metadata = await sharp(await readFile(dest)).metadata()
expect(metadata.format).to.equal('jpeg')
expect(metadata.width).to.equal(thumbnailSize.width)
}
})
it('Should be able to decode all accepted image extensions', async function () {
const extensions = [
...Object.values(MIMETYPES.IMAGE.MIMETYPE_EXT),
...Object.values(MIMETYPES.LOGO_IMAGE.MIMETYPE_EXT),
...CONSTRAINTS_FIELDS.VIDEOS.IMAGE.EXTNAME,
...CONSTRAINTS_FIELDS.VIDEO_PLAYLISTS.IMAGE.EXTNAME,
...CONSTRAINTS_FIELDS.ACTORS.IMAGE.EXTNAME,
...CONSTRAINTS_FIELDS.LOGO.IMAGE.EXTNAME
].filter(ext => ext !== '.svg') // SVG files are sanitized, not decoded
for (const ext of extensions) {
expect(isDecodableImageExtension(ext), ext).to.be.true
}
})
after(async function () {
await remove(imageDestDir)
})
+24
View File
@@ -1,4 +1,12 @@
import { ContextType } from '@peertube/peertube-models'
import { activityPubContextify, buildGlobalHTTPHeaders } from '@peertube/peertube-server/core/helpers/activity-pub-utils.js'
import { buildDigest } from '@peertube/peertube-server/core/helpers/peertube-crypto.js'
import { doRequest } from '@peertube/peertube-server/core/helpers/requests.js'
import { HTTP_SIGNATURE } from '@peertube/peertube-server/core/initializers/constants.js'
export function fakeContextFilter () {
return (data: any) => Promise.resolve(data)
}
export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
return doRequest(url, {
@@ -9,3 +17,19 @@ export function makePOSTAPRequest (url: string, body: any, httpSignature: any, h
preventSSRF: false
})
}
// Contextify the activity and send it with an HTTP signature
export async function makeSignedPOSTAPRequest (options: {
url: string
activity: any
contextType: ContextType
keyId: string
privateKey: string
}) {
const { url, activity, contextType, keyId, privateKey } = options
const body = await activityPubContextify(activity, contextType, fakeContextFilter())
const httpSignature = { keyId, key: privateKey, headers: HTTP_SIGNATURE.HEADERS_TO_SIGN_WITH_PAYLOAD }
return makePOSTAPRequest(url, body, httpSignature, buildGlobalHTTPHeaders(body, buildDigest))
}
+6
View File
@@ -38,6 +38,12 @@ export class SQLCommand {
.then(rows => rows[0].fileUrl)
}
async countActorsByUrl (url: string) {
const [ { total } ] = await this.selectQuery<{ total: string }>(`SELECT COUNT(*) AS total FROM "actor" WHERE "url" = :url`, { url })
return parseInt(total, 10)
}
setActorField (to: string, field: string, value: string) {
return this.updateQuery(`UPDATE actor SET ${this.escapeColumnName(field)} = :value WHERE url = :to`, { value, to })
}
@@ -25,7 +25,7 @@ describe('Whisper CTranslate2 transcriber', function () {
command: 'whisper-ctranslate2',
supportedModelFormats: [ 'CTranslate2' ],
languageDetection: true,
version: '0.4.4'
version: '0.5.8'
},
logger: createConsoleLogger()
})
@@ -23,6 +23,6 @@ export const engines: TranscriptionEngine[] = [
license: 'MIT',
supportedModelFormats: [ 'CTranslate2' ],
languageDetection: true,
version: '0.4.4'
version: '0.5.8'
}
]
+162 -149
View File
@@ -33,8 +33,8 @@ importers:
specifier: ^15.0.0
version: 15.0.0([email protected])
'@img/sharp-wasm32':
specifier: ^0.35.4
version: 0.35.4
specifier: ^0.35.5
version: 0.35.5
'@logtape/adaptor-winston':
specifier: ^2.3.4
version: 2.3.4(@logtape/[email protected])([email protected])
@@ -249,8 +249,8 @@ importers:
specifier: ^7.0.10
version: 7.0.10
markdown-it:
specifier: ^15.0.0
version: 15.0.0
specifier: ^15.0.3
version: 15.0.3
markdown-it-emoji:
specifier: ^3.1.0
version: 3.1.0
@@ -318,8 +318,8 @@ importers:
specifier: ^2.1.6
version: 2.1.6(@types/[email protected])(@types/[email protected])([email protected])([email protected]([email protected]))
sharp:
specifier: ^0.35.4
version: 0.35.4(@types/[email protected])
specifier: ^0.35.5
version: 0.35.5(@types/[email protected])
short-uuid:
specifier: ^6.0.3
version: 6.0.3
@@ -764,8 +764,8 @@ importers:
specifier: ^4.18.1
version: 4.18.1
markdown-it:
specifier: 15.0.0
version: 15.0.0
specifier: 15.0.3
version: 15.0.3
markdown-it-emoji:
specifier: ^3.1.0
version: 3.1.0
@@ -1764,144 +1764,144 @@ packages:
resolution: {integrity: sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==}
engines: {node: '>=18'}
'@img/[email protected].4':
resolution: {integrity: sha512-Uhfl4V4lhP2nbUVF9+hyH1+luj86f1gUFeo8ALYxFoULoU+G87D43BfeMP8XHsk9boxAnCY/bf2EHwhA7MuGsA==}
'@img/[email protected].5':
resolution: {integrity: sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==}
engines: {node: '>=20.9.0'}
cpu: [arm64]
os: [darwin]
'@img/[email protected].4':
resolution: {integrity: sha512-hWniXY3bG5qKpkKrAwPe4y+VTPmf086YQAnkxWh7uA1YrlRouWGa0M0Mxj3ZjnXFkv7/TD1bTy9lGUK26vRvWw==}
'@img/[email protected].5':
resolution: {integrity: sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==}
engines: {node: '>=20.9.0'}
cpu: [x64]
os: [darwin]
'@img/[email protected].4':
resolution: {integrity: sha512-lIsKw/BU+kjB4eZjxrYrZmwOJYi3Ajrv66iAlBmUPyKc3HpnloevB1g3wxGD9P/5BbQ1brBGl65VRRrCvQDEqA==}
'@img/[email protected].5':
resolution: {integrity: sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==}
engines: {node: '>=20.9.0'}
os: [freebsd]
'@img/[email protected].3':
resolution: {integrity: sha512-suTBPTDGrI9WodccaDdwZItTSaBYASlBk1NSfElSHrUfzu3szG6lvIF58+WiFvnfzuK8ZBFS5zE00PxqxnRiPg==}
'@img/[email protected].4':
resolution: {integrity: sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==}
cpu: [arm64]
os: [darwin]
'@img/[email protected].3':
resolution: {integrity: sha512-FVJZ5mITMobmXIz/hPDTw0EintTW5H3WfrxwLqEqjiIihlu+hVRyGrFQ60xl0Lxn7Bt3zdpevPaQi0HEzqz9fw==}
'@img/[email protected].4':
resolution: {integrity: sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==}
cpu: [x64]
os: [darwin]
'@img/[email protected].3':
resolution: {integrity: sha512-0DaL0A6Xu6sQSQFwe4iVCrKWU2cCTItnRsYsCdxAMm9NF6twAA9BKnoqy4hqz4+azQ0JHuA26qiUKsf1XJ/v5A==}
'@img/[email protected].4':
resolution: {integrity: sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==}
cpu: [arm64]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-3rbU4vqXXc3hY/OiXdl52xZvT0F1yEngWfvqudtPJg/KkyiaQw2DRsFrNzpmLvfavbwOq3qXn36GP8obHRULQA==}
'@img/[email protected].4':
resolution: {integrity: sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==}
cpu: [arm]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-cdn1OvUBwsXhbC0zSzJnNzf5MZ/mTrobawDvNXBTxe8VtqKAm0sRuEY2Evzovb/w9JMk4TvRxqt1mekSuJz64w==}
'@img/[email protected].4':
resolution: {integrity: sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==}
cpu: [ppc64]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-HjPVx7yKz+0lqdhDlTw1tt90wamBoxhiXpvl1XZpJLiHH4RCJ5yDTqH+VlYPv2fwFs89JFw4c1IexYOcQUi4IQ==}
'@img/[email protected].4':
resolution: {integrity: sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==}
cpu: [riscv64]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-neWLh+3yCNThxnfy3c4BbVBeGgt9aftno+XbT56iK28RgeDs3UOFWviLWlUu0bArYVYJaFDK+RRohbicUNCm8Q==}
'@img/[email protected].4':
resolution: {integrity: sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==}
cpu: [s390x]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-4vKmvAst9nrowcqquKFAyZJUDolUaIp8uRiN0mWFguJ1IplC9/pitXtlnnlU4aa/eJw3J7i67V+pwUL+wZGdsA==}
'@img/[email protected].4':
resolution: {integrity: sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==}
cpu: [x64]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-Y9kQaLMuNoB0bPYOOdcZMaseNrFpPodIWWMrx+CZyydf2xn68j9WYc6sWWRrDwNkzCQjKYfc68L7jKjGlHMibw==}
'@img/[email protected].4':
resolution: {integrity: sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==}
cpu: [arm64]
os: [linux]
'@img/[email protected].3':
resolution: {integrity: sha512-fj8Mv0HHfD1Rr+4I68+3agJynxDWtBFgicTbSOb9Bke6pIwzGcJ+RX/yHjmiEGFMCavY/dxvem7MyNaJF+wDiw==}
'@img/[email protected].4':
resolution: {integrity: sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==}
cpu: [x64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-De4jpEnAU8Hd5oT0j1G3uL4ZvTuipVMn7YC6vPaJhy6/7EwEae0SVAoBrUMYQbkLGDm85taVWwuPc1a44LTzCQ==}
'@img/[email protected].5':
resolution: {integrity: sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==}
engines: {node: '>=20.9.0'}
cpu: [arm64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-7OAS8gI0EReKGVN2HssHlM6umJgxF5VI3xN0p9FA91p/YO+ou5hiNghLdZ5BEHztwaaK5+bLKRf8x/o2L2nk9A==}
'@img/[email protected].5':
resolution: {integrity: sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==}
engines: {node: '>=20.9.0'}
cpu: [arm]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-2oYZJeIl4kCcMGk4ouZVjnkCtFrpQFlNEtJ6GbxzhHQchwH0NH/qEb9ykmOl29dqwMq+JhFdZn+1ak2FKhI9fQ==}
'@img/[email protected].5':
resolution: {integrity: sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==}
engines: {node: '>=20.9.0'}
cpu: [ppc64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-cPbNChoRURAWdebDIHSenxRpgEdy7JkPydSnUxRm9VvKD7m0/xVaR/8Fzlu81pk5nHEvHH87UZUA7cTtwnbJSA==}
'@img/[email protected].5':
resolution: {integrity: sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==}
engines: {node: '>=20.9.0'}
cpu: [riscv64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-RY0JFY8Fd6RonCBtHz+DvadaPkXDSI1AUn6yWL9TipqkZ1vY8w8evqdgyDFnkm4/K1ve1TvZiaePP5oSd4+WVQ==}
'@img/[email protected].5':
resolution: {integrity: sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==}
engines: {node: '>=20.9.0'}
cpu: [s390x]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-9qvvEAuk8k89TfWUoX2htWjbAMX8p+NxCppjpcg5k6xMsjhBQPTsoIh36h9Qde4WRuGpJeYnOjdosDn/cnv+OA==}
'@img/[email protected].5':
resolution: {integrity: sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==}
engines: {node: '>=20.9.0'}
cpu: [x64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-KB5jxpfWQTr0nc3xdHtWChdbifHrBGsd2SM62Eyxrl8afikm+f5qGBU75SJIZBT/S1MC8XyacdlXBMSWq6OURA==}
'@img/[email protected].5':
resolution: {integrity: sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==}
engines: {node: '>=20.9.0'}
cpu: [arm64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-f+eZJZIQNEEd26RPSW+76chwOf1XtA2Y/O+5ocVyLliHkeih3e+jhLVBdNTd2rS3IbNXK8+ug93Vf5ZXtF5Lxg==}
'@img/[email protected].5':
resolution: {integrity: sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==}
engines: {node: '>=20.9.0'}
cpu: [x64]
os: [linux]
'@img/[email protected].4':
resolution: {integrity: sha512-zQnl4Kwp7Q6NHsENtU2T/00Zi+w3AQNwz3+UaTyVBy2FpXrzXzGjndpK61onhZjRtRpQXxCTeqw19bVyXOh7jA==}
'@img/[email protected].5':
resolution: {integrity: sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==}
engines: {node: '>=20.9.0'}
'@img/[email protected].4':
resolution: {integrity: sha512-ESfNkywmCfPNyaZjxooddJQiQ+l/nTpGEOGthxiLnIHXC/CmcBixnfwUleX9mCz9ovrUUvKMap/pm8RYbzfwaA==}
'@img/[email protected].5':
resolution: {integrity: sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==}
engines: {node: '>=20.9.0'}
cpu: [wasm32]
'@img/[email protected].4':
resolution: {integrity: sha512-iNdlBX9gLVvqe2I3uIJSIKTq6wckP/DYxZtcqxm09x5Gi24DnFBmPAWZmr60ZyYMG0xlzo6goG3670ar+RXvRw==}
'@img/[email protected].5':
resolution: {integrity: sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==}
engines: {node: '>=20.9.0'}
cpu: [arm64]
os: [win32]
'@img/[email protected].4':
resolution: {integrity: sha512-kqRsbaa5CS6KHlpxnN7WhE6vAAugXyZButpRdvDWetlv6Qv4N9WTcrWzF7tXfB9T7MsoadqdI8hmwLq6UlLvtw==}
'@img/[email protected].5':
resolution: {integrity: sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==}
engines: {node: ^20.9.0}
cpu: [ia32]
os: [win32]
'@img/[email protected].4':
resolution: {integrity: sha512-XtmnYhBcrORsJ4XJngyzr/EWP0hRZLAZRFaApdKuviyqF78+ylxh2y06ZmtULAMOnObJ3ucpN0AcwSWnMowTRg==}
'@img/[email protected].5':
resolution: {integrity: sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==}
engines: {node: '>=20.9.0'}
cpu: [x64]
os: [win32]
@@ -2794,6 +2794,7 @@ packages:
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-19i/FpHmpfVLtta+Mxa2WPLkBrk+ZcgUIRT1DYHNE8q3LSJbc84DjzgD+GdVHDZGOTgsLS2nAzmvKqxw/wJdCg==}
engines: {node: ^18.19.0 || >=20.6.0}
deprecated: Package no longer supported. See https://github.com/open-telemetry/opentelemetry-js/pull/7098
peerDependencies:
'@opentelemetry/api': ^1.0.0
@@ -2882,12 +2883,14 @@ packages:
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-H19x/TX/LZdqiYOjM7fqtSxwlplC5pgelavqbQdHbhdq0q/AI/TGkM2dfGuuynTXmJPeF2HoZVoPDu+TGoW78A==}
engines: {node: ^18.19.0 || >=20.6.0}
deprecated: Use @opentelemetry/sdk-trace package
peerDependencies:
'@opentelemetry/api': '>=1.3.0 <1.10.0'
'@opentelemetry/[email protected]':
resolution: {integrity: sha512-CuvCMJmZxswhNLlM2LfuLOW3h3fZujA4hsG4B+Sz4dX2zvaXO8Ng74cnDHWD64gLszTlhiG3c0iNUjj4g+0/sA==}
engines: {node: ^18.19.0 || >=20.6.0}
deprecated: Use @opentelemetry/sdk-trace package
peerDependencies:
'@opentelemetry/api': '>=1.0.0 <1.10.0'
@@ -4936,8 +4939,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==}
[email protected].2:
resolution: {integrity: sha512-mFdDM6WqWKraGLsVb+C9CahPnzTXOefAOLq3jYcca2YZ8bEWpr++Tzj+zSaKW9+X9L5uSxcm1AZ3Y6aZJ09OhQ==}
[email protected].4:
resolution: {integrity: sha512-fwWK3Zq22l4XJJjx5mcBHGikIk+hJqO+32dPm0Jur7+rtG5x1scOjSfdT9ZKeWHPpsya/l0HHK4tDImBkTrtvA==}
[email protected]:
resolution: {integrity: sha512-h6k/zfFgusnv3i5TU08KQkVKuCPBtL/PWQbWkHUxvJrZ2nAyeaUupneemcrgn1xmqxPQsPIzwkUhOpoqPDRZuA==}
@@ -5216,12 +5219,12 @@ packages:
[email protected]:
resolution: {integrity: sha512-Vq886eXykuP5E6HcKSSStP3bJgrE6In5WKxVUvJ8XGpWWYs2xZHWqUwzCtGgEtBcxyd57KBFDPFoUfNzdaHCNg==}
[email protected].8:
resolution: {integrity: sha512-JNcyFQ64OiijEkPzUBTCe+hyPXUD/3LEldGQ6iF5LR1w00mx9o7xtDWHXBY2iItjdCFGoilOLNQbH943ut7pHA==}
[email protected].9:
resolution: {integrity: sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==}
engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16}
body-parser@2.3.0:
resolution: {integrity: sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==}
body-parser@2.4.0:
resolution: {integrity: sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==}
engines: {node: '>=18'}
[email protected]:
@@ -8243,8 +8246,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-NhmMEH2ywduD4Nty1E8uB5NqfLhAT1VR0dyvoJyStKOqCzbZmVdn/+8wj7zpDsb/fLBikpCPsWwxqKlvMmbz4g==}
[email protected].0:
resolution: {integrity: sha512-Lf8ajvVNdRpzSNB4VegxNy7gjs8gU35l4b4+ET49LrQC5PKYwLZ72u60LeJ9gv3qiaesuYjJWCyVeQmv/QWKQw==}
[email protected].3:
resolution: {integrity: sha512-+Az7Ojz3iRGu8KYMvJ6xVhvrxP3eE+vEtJX75Ow88XBpcQNV/0lGX5ZynIIBftREo4DC2jsveAMDaeltmm8QvQ==}
hasBin: true
[email protected]:
@@ -9424,6 +9427,10 @@ packages:
resolution: {integrity: sha512-h6fhOIaRrID2CbEY2fqs+7t+UXZo+MLAnU5gRIq85uFtdiUPCdsApMlHhXogKVM4HM2DVbIjGNTTYH2OcmP1vA==}
engines: {node: '>=0.6'}
[email protected]:
resolution: {integrity: sha512-5Px6J7rfHBAGUhNQ3es4YzcOdBBw0SDcVtThJml4RdnKw4tKs2epA0kPZ+K8X+WiHktT93RHVcQ/3ym5aTCgtg==}
engines: {node: '>=0.6'}
[email protected]:
resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==}
@@ -9526,8 +9533,8 @@ packages:
[email protected]:
resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==}
[email protected].0:
resolution: {integrity: sha512-UpMYezM4v5/18F28aC66AEsjXIgE02kyEMH6yLdgLXu/UTfa1Ntwck/nNLrbqJsEXW7gPb0coNO9FQse9WTovA==}
[email protected].1:
resolution: {integrity: sha512-RRieF6IyxQBkcK6pP8xOHprLTPW6QjRkbGdImtqNme+/hYVwCZkLQLdlZGOhUqXwkS9IEynaGvPJtv6XB/cz0Q==}
[email protected]:
resolution: {integrity: sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==}
@@ -10090,8 +10097,8 @@ packages:
engines: {node: '>= 0.10'}
hasBin: true
[email protected].4:
resolution: {integrity: sha512-n++8XWcj+jCOr2IOl7h8LbKnGBDY4aPbmprMONBNFdn0ImXqpGVv5zliDs0V9HbmbCQLpbuo2ej9rAoOQTvMDA==}
[email protected].5:
resolution: {integrity: sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==}
engines: {node: '>=20.9.0'}
peerDependencies:
'@types/node': '*'
@@ -12322,7 +12329,7 @@ snapshots:
devframe: 0.8.2([email protected])([email protected])
nostics: 1.2.0
optionalDependencies:
vite: 8.3.0(@types/node@24.13.4)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]4.1)([email protected])([email protected])
vite: 8.3.0(@types/node@20.19.43)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]1.0)([email protected])([email protected])
'@devframes/[email protected]([email protected]([email protected])([email protected]))([email protected])':
dependencies:
@@ -12331,7 +12338,7 @@ snapshots:
nostics: 1.2.0
zigpty: 0.2.1
optionalDependencies:
vite: 8.3.0(@types/node@24.13.4)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]4.1)([email protected])([email protected])
vite: 8.3.0(@types/node@20.19.43)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]1.0)([email protected])([email protected])
'@digitalbazaar/[email protected]':
dependencies:
@@ -12528,107 +12535,107 @@ snapshots:
'@img/[email protected]': {}
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-darwin-arm64': 1.3.3
'@img/sharp-libvips-darwin-arm64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-darwin-x64': 1.3.3
'@img/sharp-libvips-darwin-x64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
dependencies:
'@img/sharp-wasm32': 0.35.4
'@img/sharp-wasm32': 0.35.5
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].3':
'@img/[email protected].4':
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-arm64': 1.3.3
'@img/sharp-libvips-linux-arm64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-arm': 1.3.3
'@img/sharp-libvips-linux-arm': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-ppc64': 1.3.3
'@img/sharp-libvips-linux-ppc64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-riscv64': 1.3.3
'@img/sharp-libvips-linux-riscv64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-s390x': 1.3.3
'@img/sharp-libvips-linux-s390x': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linux-x64': 1.3.3
'@img/sharp-libvips-linux-x64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linuxmusl-arm64': 1.3.3
'@img/sharp-libvips-linuxmusl-arm64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optionalDependencies:
'@img/sharp-libvips-linuxmusl-x64': 1.3.3
'@img/sharp-libvips-linuxmusl-x64': 1.3.4
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
dependencies:
'@emnapi/runtime': 1.11.3
'@img/[email protected].4':
'@img/[email protected].5':
dependencies:
'@img/sharp-wasm32': 0.35.4
'@img/sharp-wasm32': 0.35.5
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optional: true
'@img/[email protected].4':
'@img/[email protected].5':
optional: true
'@inquirer/[email protected]': {}
@@ -14907,7 +14914,7 @@ snapshots:
mlly: 1.8.2
nostics: 1.2.0
nypm: 0.6.10
vite: 8.3.0(@types/node@24.13.4)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]4.1)([email protected])([email protected])
vite: 8.3.0(@types/node@20.19.43)(@vitejs/[email protected])([email protected])([email protected])([email protected])([email protected]1.0)([email protected])([email protected])
transitivePeerDependencies:
- '@modelcontextprotocol/client'
- '@modelcontextprotocol/server'
@@ -15571,7 +15578,7 @@ snapshots:
[email protected]: {}
[email protected].2: {}
[email protected].4: {}
[email protected]:
dependencies:
@@ -15920,7 +15927,7 @@ snapshots:
[email protected]: {}
[email protected].8:
[email protected].9:
dependencies:
bytes: 3.1.2
content-type: 1.0.5
@@ -15937,7 +15944,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
body-parser@2.3.0:
body-parser@2.4.0:
dependencies:
bytes: 3.1.2
content-type: 2.1.0
@@ -15945,7 +15952,7 @@ snapshots:
http-errors: 2.0.1
iconv-lite: 0.7.3
on-finished: 2.4.1
qs: 6.16.0
qs: 6.16.1
raw-body: 3.0.2
type-is: 2.1.0
transitivePeerDependencies:
@@ -17715,7 +17722,7 @@ snapshots:
dependencies:
accepts: 1.3.8
array-flatten: 1.1.1
body-parser: 1.20.8
body-parser: 1.20.9
content-disposition: 0.5.4
content-type: 1.0.5
cookie: 0.7.2
@@ -17750,7 +17757,7 @@ snapshots:
[email protected]:
dependencies:
accepts: 2.0.0
body-parser: 2.3.0
body-parser: 2.4.0
content-disposition: 1.1.0
content-type: 1.0.5
cookie: 0.7.2
@@ -19581,9 +19588,9 @@ snapshots:
[email protected]: {}
[email protected].0:
[email protected].3:
dependencies:
argparse: 3.0.2
argparse: 3.0.4
entities: 8.1.0
linkify-it: 6.1.0
mdurl: 2.1.0
@@ -20739,7 +20746,7 @@ snapshots:
[email protected]:
dependencies:
'@jest/react-is-18': [email protected]
'@jest/react-is-19': [email protected].0
'@jest/react-is-19': [email protected].1
'@jest/schemas': 30.5.0
ansi-styles: 5.2.0
@@ -20969,6 +20976,11 @@ snapshots:
es-define-property: 1.0.1
side-channel: 1.1.1
[email protected]:
dependencies:
es-define-property: 1.0.1
side-channel: 1.1.1
[email protected]: {}
[email protected]: {}
@@ -21074,7 +21086,7 @@ snapshots:
[email protected]: {}
[email protected].0: {}
[email protected].1: {}
[email protected]: {}
@@ -21751,37 +21763,37 @@ snapshots:
safe-buffer: 5.2.1
to-buffer: 1.2.2
[email protected].4(@types/[email protected]):
[email protected].5(@types/[email protected]):
dependencies:
'@img/colour': 1.1.0
detect-libc: 2.1.2
semver: 7.8.5
optionalDependencies:
'@img/sharp-darwin-arm64': 0.35.4
'@img/sharp-darwin-x64': 0.35.4
'@img/sharp-freebsd-wasm32': 0.35.4
'@img/sharp-libvips-darwin-arm64': 1.3.3
'@img/sharp-libvips-darwin-x64': 1.3.3
'@img/sharp-libvips-linux-arm': 1.3.3
'@img/sharp-libvips-linux-arm64': 1.3.3
'@img/sharp-libvips-linux-ppc64': 1.3.3
'@img/sharp-libvips-linux-riscv64': 1.3.3
'@img/sharp-libvips-linux-s390x': 1.3.3
'@img/sharp-libvips-linux-x64': 1.3.3
'@img/sharp-libvips-linuxmusl-arm64': 1.3.3
'@img/sharp-libvips-linuxmusl-x64': 1.3.3
'@img/sharp-linux-arm': 0.35.4
'@img/sharp-linux-arm64': 0.35.4
'@img/sharp-linux-ppc64': 0.35.4
'@img/sharp-linux-riscv64': 0.35.4
'@img/sharp-linux-s390x': 0.35.4
'@img/sharp-linux-x64': 0.35.4
'@img/sharp-linuxmusl-arm64': 0.35.4
'@img/sharp-linuxmusl-x64': 0.35.4
'@img/sharp-webcontainers-wasm32': 0.35.4
'@img/sharp-win32-arm64': 0.35.4
'@img/sharp-win32-ia32': 0.35.4
'@img/sharp-win32-x64': 0.35.4
'@img/sharp-darwin-arm64': 0.35.5
'@img/sharp-darwin-x64': 0.35.5
'@img/sharp-freebsd-wasm32': 0.35.5
'@img/sharp-libvips-darwin-arm64': 1.3.4
'@img/sharp-libvips-darwin-x64': 1.3.4
'@img/sharp-libvips-linux-arm': 1.3.4
'@img/sharp-libvips-linux-arm64': 1.3.4
'@img/sharp-libvips-linux-ppc64': 1.3.4
'@img/sharp-libvips-linux-riscv64': 1.3.4
'@img/sharp-libvips-linux-s390x': 1.3.4
'@img/sharp-libvips-linux-x64': 1.3.4
'@img/sharp-libvips-linuxmusl-arm64': 1.3.4
'@img/sharp-libvips-linuxmusl-x64': 1.3.4
'@img/sharp-linux-arm': 0.35.5
'@img/sharp-linux-arm64': 0.35.5
'@img/sharp-linux-ppc64': 0.35.5
'@img/sharp-linux-riscv64': 0.35.5
'@img/sharp-linux-s390x': 0.35.5
'@img/sharp-linux-x64': 0.35.5
'@img/sharp-linuxmusl-arm64': 0.35.5
'@img/sharp-linuxmusl-x64': 0.35.5
'@img/sharp-webcontainers-wasm32': 0.35.5
'@img/sharp-win32-arm64': 0.35.5
'@img/sharp-win32-ia32': 0.35.5
'@img/sharp-win32-x64': 0.35.5
'@types/node': 22.14.1
[email protected]:
@@ -23011,6 +23023,7 @@ snapshots:
sass-embedded: 1.104.1
tsx: 4.23.13
yaml: 2.9.1
optional: true
[email protected]: {}
@@ -162,7 +162,7 @@ async function generateChannelPodcastFeed (req: express.Request, res: express.Re
author: { name: CONFIG.INSTANCE.NAME, link: WEBSERVER.URL },
resourceType: 'videos',
queryString: new URL(WEBSERVER.URL + req.url).search,
medium: 'video',
medium: getPodcastMedium(req.query.enclosurePreference),
customXMLNS,
customTags
})
@@ -233,7 +233,7 @@ async function generatePlaylistPodcastFeed (req: express.Request, res: express.R
author: { name: channelName, link: ownerLink },
resourceType: 'videos',
queryString: new URL(WEBSERVER.URL + req.url).search,
medium: 'video',
medium: getPodcastMedium(req.query.enclosurePreference),
customXMLNS,
customTags
})
@@ -310,6 +310,12 @@ async function generatePodcastItem (options: {
}
}
function getPodcastMedium (enclosurePreference?: FeedEnclosurePreference) {
return enclosurePreference === 'audio'
? 'podcast'
: 'video'
}
async function addVideosToPodcastFeed (feed: Feed, videos: VideoModel[], enclosurePreference?: FeedEnclosurePreference) {
const captionsGroup = await VideoCaptionModel.listCaptionsOfMultipleVideos(videos.map(v => v.id))
+53 -2
View File
@@ -1,4 +1,5 @@
import { getSanitizeSVGOptions } from '@peertube/peertube-core-utils'
import { HttpStatusCode } from '@peertube/peertube-models'
import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils'
import { copy, remove } from 'fs-extra/esm'
import { readFile, writeFile } from 'fs/promises'
@@ -7,6 +8,35 @@ import sharp, { type Metadata, type Sharp } from 'sharp'
import { createLogger } from './logger.js'
const logger = createLogger()
// SVG files are sanitized by processSVG()
const IMAGE_LOADERS: { [extension: string]: string } = {
'.jpg': 'VipsForeignLoadJpeg',
'.jpeg': 'VipsForeignLoadJpeg',
'.png': 'VipsForeignLoadPng',
'.gif': 'VipsForeignLoadNsgif',
'.webp': 'VipsForeignLoadWebp',
'.avif': 'VipsForeignLoadHeif',
'.heic': 'VipsForeignLoadHeif',
'.tif': 'VipsForeignLoadTiff',
'.tiff': 'VipsForeignLoadTiff',
'.jxl': 'VipsForeignLoadJxl'
}
sharp.block({ operation: [ 'VipsForeignLoad' ] })
sharp.unblock({ operation: [ ...new Set(Object.values(IMAGE_LOADERS)) ] })
export function isDecodableImageExtension (extension: string) {
return !!IMAGE_LOADERS[extension.toLowerCase()]
}
export class InvalidImageError extends Error {
status = HttpStatusCode.BAD_REQUEST_400
constructor (message: string) {
super(message)
this.name = 'InvalidImageError'
}
}
export function generateImageFilename (extension = '.jpg') {
return buildUUID() + extension
@@ -61,8 +91,21 @@ export async function processImage (options: {
logger.debug('Finished processing image %s to %s.', path, destination)
}
export async function processImagesOrCleanup<T> (tasks: { destination: string, process: () => Promise<T> }[]) {
const results = await Promise.allSettled(tasks.map(t => t.process()))
const failed = results.find((r): r is PromiseRejectedResult => r.status === 'rejected')
if (failed) {
await Promise.all(tasks.map(t => remove(t.destination)))
throw failed.reason as Error
}
return results.map(r => (r as PromiseFulfilledResult<T>).value)
}
export async function getImageSize (path: string) {
const metadata = await sharp(path).metadata()
const metadata = await getMetadata(sharp(path))
return {
width: metadata.width,
@@ -108,7 +151,7 @@ async function sharpProcessor (options: {
animated
})
const metadata = await sharpInstance.metadata()
const metadata = await getMetadata(sharpInstance)
if (animated && metadata.pages > 200) {
logger.info('Too much frames in animated image ' + path + ', skipping animation')
@@ -139,6 +182,14 @@ async function sharpProcessor (options: {
}
}
async function getMetadata (sharpInstance: Sharp) {
try {
return await sharpInstance.metadata()
} catch (err) {
throw new InvalidImageError('Cannot read image: ' + err.message)
}
}
async function autoResize (options: {
sharpInstance: Sharp
metadata: Metadata
+14 -1
View File
@@ -49,6 +49,8 @@ export type PeerTubeRequestOptions = {
followRedirect?: boolean
preventCrossHostRedirect?: boolean
// Support AbortSignal for request cancellation (e.g., on job timeout)
signal?: AbortSignal
} & Pick<OptionsInit, 'headers' | 'json' | 'method' | 'searchParams'>
@@ -131,6 +133,17 @@ const unsafeSSRFGot = got.extend({
}
],
beforeRedirect: [
(options, response) => {
if (options.context?.preventCrossHostRedirect !== true) return
const redirectUrl = buildUrl(options.url)
if (redirectUrl.host === new URL(response.url).host) return
throw new Error(`Cannot follow redirection of ${response.url} to another host (${redirectUrl.href})`)
}
],
beforeRetry: [
(error: RequestError, retryCount: number) => {
logger.debug('Retrying request to %s.', error.request.requestUrl, { retryCount, error: buildRequestError(error) })
@@ -276,7 +289,7 @@ function getUserAgent () {
function buildGotOptions (options: PeerTubeRequestOptions): OptionsOfUnknownResponseBodyWrapped {
const { activityPub, bodyKBLimit = 3000 } = options
const context = { bodyKBLimit, httpSignature: options.httpSignature }
const context = { bodyKBLimit, httpSignature: options.httpSignature, preventCrossHostRedirect: options.preventCrossHostRedirect }
let headers = options.headers || {}
+5 -3
View File
@@ -39,10 +39,12 @@ export function buildAvailableActivities (): ActivityType[] {
// ---------------------------------------------------------------------------
export async function fetchAP <T> (url: string, moreOptions: PeerTubeRequestOptions = {}) {
export async function fetchAP<T> (url: string, moreOptions: PeerTubeRequestOptions = {}) {
const options = {
activityPub: true,
preventCrossHostRedirect: true,
httpSignature: CONFIG.FEDERATION.SIGN_FEDERATED_FETCHES
? await buildSignedRequestOptions({ hasPayload: false })
: undefined,
@@ -53,7 +55,7 @@ export async function fetchAP <T> (url: string, moreOptions: PeerTubeRequestOpti
return doJSONRequest<T>(url, options)
}
export async function fetchAPObjectIfNeeded <T extends (ActivityObject | ActivityPubActor)> (object: APObjectId) {
export async function fetchAPObjectIfNeeded<T extends (ActivityObject | ActivityPubActor)> (object: APObjectId) {
if (typeof object === 'string') {
const { body } = await fetchAP<Exclude<T, string>>(object)
@@ -68,7 +70,7 @@ export async function findLatestAPRedirection (url: string, iteration = 1) {
const { headers } = await fetchAP(url, { followRedirect: false })
if (headers.location) return findLatestAPRedirection(headers.location, iteration + 1)
if (headers.location) return findLatestAPRedirection(new URL(headers.location, url).href, iteration + 1)
return url
}
@@ -56,7 +56,7 @@ export async function fetchActorFollowsCount (actorObject: ActivityPubActor) {
async function fetchActorTotalItems (url: string) {
try {
const { body } = await fetchAP<ActivityPubOrderedCollection<unknown>>(url)
const { body } = await fetchAP<ActivityPubOrderedCollection<unknown>>(url, { preventCrossHostRedirect: false })
return body.totalItems || 0
} catch (err) {
@@ -50,7 +50,8 @@ export async function refreshVideoIfNeeded (options: {
const videoUpdater = new APVideoUpdater(videoObject, video, video.url)
await videoUpdater.update()
await syncVideoExternalAttributes(video, videoObject, options.syncParam)
// Rates have already been updated by the updater
await syncVideoExternalAttributes(video, videoObject, options.syncParam, { skipRates: true })
ActorFollowHealthCache.Instance.addGoodServerId(video.VideoChannel.Actor.serverId)
@@ -149,7 +149,7 @@ export abstract class APVideoAbstractBuilder {
protected async updateChapters (video: MVideoFull) {
if (!this.videoObject.hasParts || typeof this.videoObject.hasParts !== 'string') return
const { body } = await fetchAP<VideoChaptersObject>(this.videoObject.hasParts)
const { body } = await fetchAP<VideoChaptersObject>(this.videoObject.hasParts, { preventCrossHostRedirect: false })
if (!isVideoChaptersObjectValid(body)) {
logger.warn('Chapters AP object is not valid, skipping', { body })
return
@@ -6,6 +6,7 @@ import { VideoCommentModel } from '@server/models/video/video-comment.js'
import { VideoShareModel } from '@server/models/video/video-share.js'
import { VideoModel } from '@server/models/video/video.js'
import { MVideo } from '@server/types/models/index.js'
import validator from 'validator'
import { fetchAP } from '../../activity.js'
import { crawlCollectionPage } from '../../crawl.js'
import { addVideoShares } from '../../share.js'
@@ -23,13 +24,18 @@ export type SyncParam = {
export function syncVideoExternalAttributes (
video: MVideo,
fetchedVideo: VideoObject,
syncParam: Pick<SyncParam, 'rates' | 'shares' | 'comments'>
syncParam: Pick<SyncParam, 'rates' | 'shares' | 'comments'>,
options: {
skipRates?: boolean
} = {}
) {
return logger.withContext([ video.uuid, video.url ], async () => {
logger.info('Adding likes/dislikes/shares/comments of video %s.', video.uuid)
const ratePromise = updateVideoRates(video, fetchedVideo)
if (syncParam.rates) await ratePromise
if (options.skipRates !== true) {
const ratePromise = updateVideoRates(video, fetchedVideo)
if (syncParam.rates) await ratePromise
}
await syncShares(video, fetchedVideo, syncParam.shares)
@@ -37,16 +43,24 @@ export function syncVideoExternalAttributes (
})
}
// Never throws: rates are not essential, so a remote error must not fail the video creation/update
export async function updateVideoRates (video: MVideo, fetchedVideo: VideoObject) {
const [ likes, dislikes ] = await Promise.all([
getRatesCount('like', video, fetchedVideo),
getRatesCount('dislike', video, fetchedVideo)
])
try {
const [ likes, dislikes ] = await Promise.all([
getRatesCount('like', video, fetchedVideo),
getRatesCount('dislike', video, fetchedVideo)
])
return runInReadCommittedTransaction(async t => {
await VideoModel.updateRatesOf(video.id, 'like', likes, t)
await VideoModel.updateRatesOf(video.id, 'dislike', dislikes, t)
})
// Remote video may not provide likes/dislikes collections
if (likes === undefined && dislikes === undefined) return
await runInReadCommittedTransaction(async t => {
if (likes !== undefined) await VideoModel.updateRatesOf(video.id, 'like', likes, t)
if (dislikes !== undefined) await VideoModel.updateRatesOf(video.id, 'dislike', dislikes, t)
})
} catch (err) {
logger.warn('Cannot sync rates of video %s.', video.url, { err })
}
}
// ---------------------------------------------------------------------------
@@ -62,14 +76,14 @@ async function getRatesCount (type: 'like' | 'dislike', video: MVideo, fetchedVi
logger.info('Sync %s of video %s', type, video.url)
const { body } = await fetchAP<ActivityPubOrderedCollection<any>>(uri)
const { body } = await fetchAP<ActivityPubOrderedCollection<any>>(uri, { preventCrossHostRedirect: false })
if (isNaN(body.totalItems)) {
logger.error('Cannot sync %s of video %s, totalItems is not a number', type, video.url, { body })
if (!validator.default.isInt(body?.totalItems + '', { min: 0 })) {
logger.warn('Cannot sync %s of video %s, totalItems is not a positive integer', type, video.url, { body })
return
}
return body.totalItems
return parseInt(body.totalItems + '', 10)
}
function syncShares (video: MVideo, fetchedVideo: VideoObject, isSync: boolean) {
@@ -115,7 +115,7 @@ async function updateObjectIfNeeded<T> (options: {
return on404OrTombstone()
}
logger.debug('Remote AP object %s is unavailable.', url)
logger.debug('Remote AP object %s is unavailable.', url, { err })
const unavailability = await Redis.Instance.addAPUnavailability(url)
if (unavailability >= AP_CLEANER.UNAVAILABLE_TRESHOLD) {
+68 -42
View File
@@ -1,6 +1,6 @@
import { ActivityPubActorType, ActorImageType, ActorImageType_Type } from '@peertube/peertube-models'
import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils'
import { processImage } from '@server/helpers/image-utils.js'
import { processImage, processImagesOrCleanup } from '@server/helpers/image-utils.js'
import { ActorReservedModel } from '@server/models/actor/actor-reserved.js'
import { ActorModel } from '@server/models/actor/actor.js'
import { remove } from 'fs-extra/esm'
@@ -39,44 +39,15 @@ export async function updateLocalActorImageFiles (options: {
}) {
const { accountOrChannel, imagePhysicalFile, type, sendActorUpdate } = options
const processImageSize = async (imageSize: { width: number, height: number }) => {
const extension = getLowercaseExtension(imagePhysicalFile.path)
let processedImages: ProcessedActorImage[]
const imageName = buildUUID() + extension
const destination = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, imageName)
await processImage({ path: imagePhysicalFile.path, destination, newSize: imageSize, keepOriginal: true })
return {
imageName,
imageSize
}
try {
processedImages = await generateActorImageSizes(imagePhysicalFile.path, type)
} finally {
await remove(imagePhysicalFile.path)
}
const processedImages = await Promise.all(ACTOR_IMAGES_SIZE[type].map(processImageSize))
await remove(imagePhysicalFile.path)
return retryTransactionWrapper(() =>
sequelizeTypescript.transaction(async t => {
const actorImagesInfo = processedImages.map(({ imageName, imageSize }) => ({
name: imageName,
fileUrl: null,
height: imageSize.height,
width: imageSize.width,
cached: false
}))
const updatedActor = await updateActorImages(accountOrChannel.Actor, type, actorImagesInfo, t)
await updatedActor.save({ transaction: t })
if (sendActorUpdate) {
await sendUpdateActor(accountOrChannel, t)
}
return type === ActorImageType.AVATAR
? updatedActor.Avatars
: updatedActor.Banners
})
)
return saveLocalActorImages({ accountOrChannel, processedImages, type, sendActorUpdate })
}
export async function deleteLocalActorImageFile (accountOrChannel: MAccountDefault | MChannelDefault, type: ActorImageType_Type) {
@@ -107,12 +78,11 @@ export async function regenerateActorImageFiles (options: {
const physicalFilePath = image.getFSPath()
return updateLocalActorImageFiles({
accountOrChannel,
imagePhysicalFile: { path: physicalFilePath },
type,
sendActorUpdate: true
})
// Keep the original image if generation fails, since it is still used by the actor
const processedImages = await generateActorImageSizes(physicalFilePath, type)
await remove(physicalFilePath)
return saveLocalActorImages({ accountOrChannel, processedImages, type, sendActorUpdate: true })
}
// ---------------------------------------------------------------------------
@@ -134,3 +104,59 @@ export async function findAvailableLocalActorName (baseName: string, transaction
export async function loadReservedActorName (baseName: string, transaction?: Transaction) {
return await ActorModel.loadLocalByName(baseName, transaction) ?? await ActorReservedModel.loadByName(baseName, transaction)
}
// ---------------------------------------------------------------------------
// Private
// ---------------------------------------------------------------------------
type ProcessedActorImage = { imageName: string, imageSize: { width: number, height: number } }
function generateActorImageSizes (path: string, type: ActorImageType_Type): Promise<ProcessedActorImage[]> {
const extension = getLowercaseExtension(path)
return processImagesOrCleanup(ACTOR_IMAGES_SIZE[type].map(imageSize => {
const imageName = buildUUID() + extension
const destination = join(CONFIG.STORAGE.ACTOR_IMAGES_DIR, imageName)
return {
destination,
process: async () => {
await processImage({ path, destination, newSize: imageSize, keepOriginal: true })
return { imageName, imageSize }
}
}
}))
}
function saveLocalActorImages (options: {
accountOrChannel: MAccountDefault | MChannelDefault
processedImages: ProcessedActorImage[]
type: ActorImageType_Type
sendActorUpdate: boolean
}) {
const { accountOrChannel, processedImages, type, sendActorUpdate } = options
return retryTransactionWrapper(() =>
sequelizeTypescript.transaction(async t => {
const actorImagesInfo = processedImages.map(({ imageName, imageSize }) => ({
name: imageName,
fileUrl: null,
height: imageSize.height,
width: imageSize.width,
cached: false
}))
const updatedActor = await updateActorImages(accountOrChannel.Actor, type, actorImagesInfo, t)
await updatedActor.save({ transaction: t })
if (sendActorUpdate) {
await sendUpdateActor(accountOrChannel, t)
}
return type === ActorImageType.AVATAR
? updatedActor.Avatars
: updatedActor.Banners
})
)
}
+30 -26
View File
@@ -20,7 +20,7 @@ const logger = createLogger('thumbnail')
type ImageSize = { height: number, width: number, aspectRatio: ThumbnailAspectRatio }
export function createLocalPlaylistThumbnailsFromImage (options: {
export async function createLocalPlaylistThumbnailsFromImage (options: {
inputPath: string
playlist: MVideoPlaylistThumbnail
automaticallyGenerated: boolean
@@ -28,18 +28,22 @@ export function createLocalPlaylistThumbnailsFromImage (options: {
}) {
const { inputPath, playlist, automaticallyGenerated, keepOriginal = false } = options
return Promise.all(
CONFIG.THUMBNAILS.SIZES.map((size, i) => {
return _createLocalPlaylistThumbnailFromImage({
inputPath,
playlist,
automaticallyGenerated,
size,
// Keep original image until the last thumbnail is generated
keepOriginal: keepOriginal || i !== CONFIG.THUMBNAILS.SIZES.length - 1
})
})
)
try {
return await Promise.all(
CONFIG.THUMBNAILS.SIZES.map(size =>
// We'll delete origin file ourselves after all thumbnails are generated, to avoid deleting it before generating all thumbnails
_createLocalPlaylistThumbnailFromImage({ inputPath, playlist, automaticallyGenerated, size, keepOriginal: true })
)
)
} finally {
if (!keepOriginal) {
try {
await remove(inputPath)
} catch (err) {
logger.error('Cannot remove original image after thumbnail generation.', { err })
}
}
}
}
function _createLocalPlaylistThumbnailFromImage (options: {
@@ -125,22 +129,22 @@ export async function createLocalVideoThumbnailsFromImage (options: {
}) {
const { inputPath, automaticallyGenerated, video, keepOriginal = false } = options
const thumbnails = await Promise.all(
CONFIG.THUMBNAILS.SIZES.map(size =>
// We'll delete origin file ourselves after all thumbnails are generated, to avoid deleting it before generating all thumbnails
_createLocalVideoThumbnailFromImage({ inputPath, video, automaticallyGenerated, size, keepOriginal: true })
try {
return await Promise.all(
CONFIG.THUMBNAILS.SIZES.map(size =>
// We'll delete origin file ourselves after all thumbnails are generated, to avoid deleting it before generating all thumbnails
_createLocalVideoThumbnailFromImage({ inputPath, video, automaticallyGenerated, size, keepOriginal: true })
)
)
)
if (!keepOriginal) {
try {
await remove(inputPath)
} catch (err) {
logger.error('Cannot remove original image after thumbnail generation.', { err })
} finally {
if (!keepOriginal) {
try {
await remove(inputPath)
} catch (err) {
logger.error('Cannot remove original image after thumbnail generation.', { err })
}
}
}
return thumbnails
}
function _createLocalVideoThumbnailFromImage (options: {
+22 -19
View File
@@ -1,6 +1,6 @@
import { LogoType, UploadImageType, UploadImageType_Type } from '@peertube/peertube-models'
import { buildUUID, getLowercaseExtension } from '@peertube/peertube-node-utils'
import { buildImageSize, processImage, processSVG } from '@server/helpers/image-utils.js'
import { buildImageSize, processImage, processImagesOrCleanup, processSVG } from '@server/helpers/image-utils.js'
import { UploadImageModel } from '@server/models/application/upload-image.js'
import { remove } from 'fs-extra/esm'
import { retryTransactionWrapper } from '../helpers/database-utils.js'
@@ -15,8 +15,13 @@ export async function replaceUploadImage (options: {
}) {
const { actor, imagePhysicalFile, type } = options
const processedImages = await generateImageSizes(imagePhysicalFile.path, type)
await remove(imagePhysicalFile.path)
let processedImages: { imageName: string, imageSize: { width: number, height: number } }[]
try {
processedImages = await generateImageSizes(imagePhysicalFile.path, type)
} finally {
await remove(imagePhysicalFile.path)
}
return retryTransactionWrapper(() =>
sequelizeTypescript.transaction(async t => {
@@ -55,25 +60,23 @@ async function generateImageSizes (imagePath: string, type: UploadImageType_Type
return [ { imageName, imageSize: { width: null, height: null } } ]
}
return Promise.all(UPLOAD_IMAGES_SIZE[type].map(size => generateImageSize({ ...size, imagePath })))
}
async function generateImageSize (options: {
imagePath: string
width: number
height: number
}) {
const { imagePath, width, height } = options
const imageSize = await buildImageSize(imagePath, { width, height })
const extension = getLowercaseExtension(imagePath)
const imageName = buildUUID() + extension
const destination = UploadImageModel.getFSPathOf(imageName)
await processImage({ path: imagePath, destination, newSize: imageSize, keepOriginal: true })
return processImagesOrCleanup(UPLOAD_IMAGES_SIZE[type].map(({ width, height }) => {
const imageName = buildUUID() + extension
const destination = UploadImageModel.getFSPathOf(imageName)
return { imageName, imageSize }
return {
destination,
process: async () => {
const imageSize = await buildImageSize(imagePath, { width, height })
await processImage({ path: imagePath, destination, newSize: imageSize, keepOriginal: true })
return { imageName, imageSize }
}
}
}))
}
// ---------------------------------------------------------------------------