Skip to content

Commit

Permalink
disallow new lines
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed Apr 12, 2024
1 parent c8b212f commit dbbe3d0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/utils/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ export function isDocumentString(str: any): boolean {
return false;
}

const invalidPathRegex = /[!%^<>`]/;
const invalidPathRegex = /[!%^<>`\n]/;
/**
* Checkes whether the `str` contains any path illegal characters.
*
* A string may sometimes look like a path but is not (like an SDL of a simple
* GraphQL schema). To make sure we don't yield false-positives in such cases,
* we disallow new lines in paths (even thouhg most Unix systems support new
* lines in file names).
*/
export function isValidPath(str: any): boolean {
return typeof str === 'string' && !invalidPathRegex.test(str);
}
Expand Down

0 comments on commit dbbe3d0

Please sign in to comment.