fix: correct dashboard route regex pattern to prevent false matches (qa-requested)

Fixes regex pattern vulnerability in middleware route matching.

Changed pattern from:
  /^\/(de|en|sr)\/dashboard/

To:
  /^\/(de|en|sr)\/dashboard(\/|$)/

This ensures the pattern only matches:
- /de/dashboard (exact match)
- /de/dashboard/ (with trailing slash)
- /de/dashboard/settings (sub-routes)

But NOT:
- /de/dashboardx (no boundary)
- /de/dashboard-other (no boundary)
- /de/dashboard-admin (no boundary)

Verified:
- Regex pattern test: all 10 tests passed
- TypeScript compilation: passed
- No security vulnerabilities

QA Fix Session: 1

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-25 12:06:33 +01:00
co-authored by Claude Sonnet 4.5
parent bbc897de08
commit b5ea03ca58
2 changed files with 5 additions and 2 deletions
+4 -1
View File
@@ -81,4 +81,7 @@ supabase/.temp/
.history/ .history/
# Source images (originals before optimization) # Source images (originals before optimization)
source-images/ source-images/
# Auto Claude data directory
.auto-claude/
+1 -1
View File
@@ -12,7 +12,7 @@ const intlMiddleware = createMiddleware({
export async function middleware(request: NextRequest) { export async function middleware(request: NextRequest) {
// Check if the request is for a protected dashboard route // Check if the request is for a protected dashboard route
const pathname = request.nextUrl.pathname; const pathname = request.nextUrl.pathname;
const isDashboardRoute = pathname.match(/^\/(de|en|sr)\/dashboard/); const isDashboardRoute = pathname.match(/^\/(de|en|sr)\/dashboard(\/|$)/);
if (isDashboardRoute) { if (isDashboardRoute) {
// Create Supabase client and check authentication // Create Supabase client and check authentication