We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents cce868e + 0bbc73b commit ea31178Copy full SHA for ea31178
1 file changed
apps/api/src/evidence-forms/evidence-forms.service.ts
@@ -196,16 +196,16 @@ export class EvidenceFormsService {
196
);
197
}
198
199
- const base64Pattern = /^[A-Za-z0-9+/]+={0,2}$/;
200
- if (!base64Pattern.test(normalized)) {
+ const fileBuffer = Buffer.from(normalized, 'base64');
+
201
+ if (fileBuffer.toString('base64') !== normalized) {
202
throw new BadRequestException(
203
'Invalid file data. Expected base64 string.',
204
205
206
- const fileBuffer = Buffer.from(normalized, 'base64');
207
if (!fileBuffer.length) {
208
- throw new BadRequestException('File cannot be empty');
+ throw new BadRequestException('File cannot be empty.');
209
210
211
return fileBuffer;
0 commit comments