in reply to Re: How to validate a directory string?
in thread How to validate a directory string?

There are good reasons to be a little more selective than that. For instance, allowing things that are not visible ascii characters is generally a bad idea, and including visible ascii characters that typically relate to "shell magic" (vertical bar, ampersand, the various brackets and quotes) can also lead to trouble. More and more, unix-heads are getting used to handling spaces in file names, but allowing TAB, CR and LF as well would be asking for trouble, IMHO.

I'd be more inclined to something like

/\A[^\x00-\x1f\x7f&*?|\\"'`<>{}()[\]]+\z/ # allows space and "safe" punctuation
Of course, that still doesn't address the question of bytes outside the 7-bit ascii range, which includes the whole domain of utf8 wide characters. For that part of the issue, there isn't enough information in the OP to provide a basis for appropriate advice. (Would utf8 file names be allowable/sensible? What is expectable/possible regarding non-ascii content in the input strings?)