The check for `empty($text)` is simply not good enough. It looks like it just needs to be `if ($text is not a valid filename on any of the expected/supported filesystems)` E.g. `D:\foo..bar` is probably illegal, not sure what the previous steps do.