Skip to content

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

Fix toArray sanitizer

Chocobozzzcb086b3afb7d
diff --git a/server/core/helpers/custom-validators/misc.ts b/server/core/helpers/custom-validators/misc.ts
index 96d9036dc5..9f438fa3b7 100644
--- a/server/core/helpers/custom-validators/misc.ts
+++ b/server/core/helpers/custom-validators/misc.ts
@@ -169,7 +169,7 @@ export function toArray (value: any) {
if (!value) return []
if (isArray(value)) return value
- if (value?.[0]) return Object.values(value)
+ if (typeof value === 'object' && value?.[0]) return Object.values(value)
return [ value ]
}
@@ -178,7 +178,7 @@ export function toIntArray (value: any) {
if (!value) return []
if (isArray(value)) return value.map(v => validator.default.toInt(v))
- if (value?.[0]) return Object.values(value).map(v => validator.default.toInt(v + ''))
+ if (typeof value === 'object' && value?.[0]) return Object.values(value).map(v => validator.default.toInt(v + ''))
if (typeof value === 'string' || typeof value === 'number') return [ validator.default.toInt(value + '') ]