diff --git a/app/client/src/workers/validations.ts b/app/client/src/workers/validations.ts index 4b5d9c211e..b466dfb781 100644 --- a/app/client/src/workers/validations.ts +++ b/app/client/src/workers/validations.ts @@ -11,11 +11,9 @@ import _, { isObject, isPlainObject, isString, - startsWith, toString, uniq, } from "lodash"; -import { WidgetProps } from "../widgets/BaseWidget"; import moment from "moment"; import { ValidationConfig } from "constants/PropertyControlConstants"; @@ -657,6 +655,7 @@ export const VALIDATORS: Record = { parsed: config.params?.default || "", message: `${WIDGET_TYPE_VALIDATION_ERROR}: ${getExpectedType(config)}`, }; + const base64Regex = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/; const base64ImageRegex = /^data:image\/.*;base64/; const imageUrlRegex = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpeg|jpg|gif|png)??(?:&?[^=&]*=[^=&]*)*/; if ( @@ -677,7 +676,7 @@ export const VALIDATORS: Record = { parsed: value, }; } - if (btoa(atob(value)) === value) { + if (base64Regex.test(value) && btoa(atob(value)) === value) { return { isValid: true, parsed: `data:image/png;base64,${value}` }; } }