adding check for base64 (#6532)
This commit is contained in:
parent
92f4d878ab
commit
478a2a3147
|
|
@ -11,11 +11,9 @@ import _, {
|
||||||
isObject,
|
isObject,
|
||||||
isPlainObject,
|
isPlainObject,
|
||||||
isString,
|
isString,
|
||||||
startsWith,
|
|
||||||
toString,
|
toString,
|
||||||
uniq,
|
uniq,
|
||||||
} from "lodash";
|
} from "lodash";
|
||||||
import { WidgetProps } from "../widgets/BaseWidget";
|
|
||||||
|
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { ValidationConfig } from "constants/PropertyControlConstants";
|
import { ValidationConfig } from "constants/PropertyControlConstants";
|
||||||
|
|
@ -657,6 +655,7 @@ export const VALIDATORS: Record<ValidationTypes, Validator> = {
|
||||||
parsed: config.params?.default || "",
|
parsed: config.params?.default || "",
|
||||||
message: `${WIDGET_TYPE_VALIDATION_ERROR}: ${getExpectedType(config)}`,
|
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 base64ImageRegex = /^data:image\/.*;base64/;
|
||||||
const imageUrlRegex = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpeg|jpg|gif|png)??(?:&?[^=&]*=[^=&]*)*/;
|
const imageUrlRegex = /(http(s?):)([/|.|\w|\s|-])*\.(?:jpeg|jpg|gif|png)??(?:&?[^=&]*=[^=&]*)*/;
|
||||||
if (
|
if (
|
||||||
|
|
@ -677,7 +676,7 @@ export const VALIDATORS: Record<ValidationTypes, Validator> = {
|
||||||
parsed: value,
|
parsed: value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (btoa(atob(value)) === value) {
|
if (base64Regex.test(value) && btoa(atob(value)) === value) {
|
||||||
return { isValid: true, parsed: `data:image/png;base64,${value}` };
|
return { isValid: true, parsed: `data:image/png;base64,${value}` };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user