Browse Source

Filter out invalid images from peertube

develop
Chocobozzz 3 days ago
parent
commit
5800f354cc
No known key found for this signature in database GPG Key ID: 583A612D890159BE
1 changed files with 21 additions and 19 deletions
  1. +21
    -19
      server/lib/activitypub/actors/shared/object-to-model-attributes.ts

+ 21
- 19
server/lib/activitypub/actors/shared/object-to-model-attributes.ts View File

@@ -35,31 +35,33 @@ function getImagesInfoFromObject (actorObject: ActivityPubActor, type: ActorImag
? actorObject.icons || actorObject.icon
: actorObject.image

return normalizeIconOrImage(iconsOrImages).map(iconOrImage => {
const mimetypes = MIMETYPES.IMAGE
return normalizeIconOrImage(iconsOrImages)
.map(iconOrImage => {
const mimetypes = MIMETYPES.IMAGE

if (iconOrImage.type !== 'Image' || !isActivityPubUrlValid(iconOrImage.url)) return undefined
if (iconOrImage.type !== 'Image' || !isActivityPubUrlValid(iconOrImage.url)) return undefined

let extension: string
let extension: string

if (iconOrImage.mediaType) {
extension = mimetypes.MIMETYPE_EXT[iconOrImage.mediaType]
} else {
const tmp = getLowercaseExtension(iconOrImage.url)
if (iconOrImage.mediaType) {
extension = mimetypes.MIMETYPE_EXT[iconOrImage.mediaType]
} else {
const tmp = getLowercaseExtension(iconOrImage.url)

if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp
}
if (mimetypes.EXT_MIMETYPE[tmp] !== undefined) extension = tmp
}

if (!extension) return undefined
if (!extension) return undefined

return {
name: buildUUID() + extension,
fileUrl: iconOrImage.url,
height: iconOrImage.height,
width: iconOrImage.width,
type
}
})
return {
name: buildUUID() + extension,
fileUrl: iconOrImage.url,
height: iconOrImage.height,
width: iconOrImage.width,
type
}
})
.filter(i => !!i)
}

function getActorDisplayNameFromObject (actorObject: ActivityPubActor) {


Loading…
Cancel
Save