add validation for non-printable chars in CLI (#6682)

This commit is contained in:
André Alves 2023-04-12 16:30:09 -03:00 committed by GitHub
parent a9c22994e4
commit 3356023443
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
add validation for non-printable characters

View file

@ -24,6 +24,9 @@ export async function projectName(ctx: Pick<Context, 'cwd' | 'prompt' | 'project
if (!isEmpty(value)) {
return `Directory is not empty!`;
}
// Check for non-printable characters
if (value.match(/[^\x20-\x7E]/g) !== null)
return `Invalid non-printable character present!`;
return true;
},
});