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!

title length validation

Blue Mouse9211cfac4c63
diff --git a/backend/apps/cloud/src/og-image/og-image.service.ts b/backend/apps/cloud/src/og-image/og-image.service.ts
index cc9081ee4..f2386bc2e 100644
--- a/backend/apps/cloud/src/og-image/og-image.service.ts
+++ b/backend/apps/cloud/src/og-image/og-image.service.ts
@@ -1,4 +1,8 @@
-import { Injectable, OnModuleDestroy } from '@nestjs/common'
+import {
+ BadRequestException,
+ Injectable,
+ OnModuleDestroy,
+} from '@nestjs/common'
import handlebars from 'handlebars'
import puppeteer, { type Browser } from 'puppeteer'
@@ -241,6 +245,11 @@ export class OgImageService implements OnModuleDestroy {
async getOgImage(title: string) {
const decodedTitle = decodeURIComponent(title)
+
+ if (decodedTitle.length > 255) {
+ throw new BadRequestException('Title is too long')
+ }
+
const html = this.getOgHTML(decodedTitle)
const browser = await this.getBrowser()