This commit is contained in:
2026-04-16 17:21:48 +03:00
parent c8fa4c442d
commit c8e7e4e927
116 changed files with 3720 additions and 4197 deletions
@@ -3,8 +3,8 @@ import {
NestInterceptor,
ExecutionContext,
CallHandler,
} from '@nestjs/common';
import { Observable } from 'rxjs';
} from "@nestjs/common";
import { Observable } from "rxjs";
/**
* Strips HTML/script tags from all string values in the request body.
@@ -15,7 +15,7 @@ export class SanitizeInterceptor implements NestInterceptor {
intercept(context: ExecutionContext, next: CallHandler): Observable<unknown> {
const request = context.switchToHttp().getRequest();
if (request.body && typeof request.body === 'object') {
if (request.body && typeof request.body === "object") {
request.body = this.sanitize(request.body);
}
@@ -23,7 +23,7 @@ export class SanitizeInterceptor implements NestInterceptor {
}
private sanitize(value: unknown): unknown {
if (typeof value === 'string') {
if (typeof value === "string") {
return this.stripTags(value);
}
@@ -31,7 +31,7 @@ export class SanitizeInterceptor implements NestInterceptor {
return value.map((item) => this.sanitize(item));
}
if (value !== null && typeof value === 'object') {
if (value !== null && typeof value === "object") {
const sanitized: Record<string, unknown> = {};
for (const [key, val] of Object.entries(value)) {
sanitized[key] = this.sanitize(val);
@@ -43,6 +43,6 @@ export class SanitizeInterceptor implements NestInterceptor {
}
private stripTags(input: string): string {
return input.replace(/<[^>]*>/g, '');
return input.replace(/<[^>]*>/g, "");
}
}