Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

fix: Only return brandKeywords when the JSON decodes to string[]

Blue Mouse135966cab1dd
diff --git a/backend/apps/cloud/src/project/project.controller.ts b/backend/apps/cloud/src/project/project.controller.ts
index 983d0ccfe..63b485a23 100644
--- a/backend/apps/cloud/src/project/project.controller.ts
+++ b/backend/apps/cloud/src/project/project.controller.ts
@@ -1821,7 +1821,11 @@ export class ProjectController {
const result = _omit(project, ['admin', 'passwordHash', 'share']) as any
if (result.brandKeywords) {
try {
- result.brandKeywords = JSON.parse(result.brandKeywords)
+ const parsed = JSON.parse(result.brandKeywords)
+ result.brandKeywords =
+ Array.isArray(parsed) && parsed.every((item) => typeof item === 'string')
+ ? parsed
+ : null
} catch {
result.brandKeywords = null
}
@@ -1952,7 +1956,11 @@ export class ProjectController {
let parsedBrandKeywords: string[] | null = null
if (project.brandKeywords) {
try {
- parsedBrandKeywords = JSON.parse(project.brandKeywords)
+ const parsed = JSON.parse(project.brandKeywords)
+ parsedBrandKeywords =
+ Array.isArray(parsed) && parsed.every((item) => typeof item === 'string')
+ ? parsed
+ : null
} catch {
parsedBrandKeywords = null
}