diff --git a/src/data-sources/components/DataSourceForm.tsx b/src/data-sources/components/DataSourceForm.tsx index 79ca93a7..9178390a 100644 --- a/src/data-sources/components/DataSourceForm.tsx +++ b/src/data-sources/components/DataSourceForm.tsx @@ -37,8 +37,12 @@ export const DataSourceForm = ( { }; const onDisplayNameChange = ( displayNameInput: string | undefined ) => { - setDisplayName( displayNameInput ?? '' ); - handleOnChange( 'display_name', displayNameInput ?? '' ); + const sanitizedDisplayName = displayNameInput + ?.toString() + .trim() + .replace( /[^a-zA-Z0-9-_ ]/g, '' ); + setDisplayName( sanitizedDisplayName ?? '' ); + handleOnChange( 'display_name', sanitizedDisplayName ?? '' ); }; return (