When you generate a filename that contains square brackets, and a hyphen within that, the skip checking code can subsequently crash if the characters either side of the hyphen do not form a valid range.
For example, "[i-S]" in a filename will crash.
Given that this check is meant to be searching for existing items, not actually applying a regular expression, I've used quotemeta on the whole filename.
When you generate a filename that contains square brackets, and a hyphen within that, the skip checking code can subsequently crash if the characters either side of the hyphen do not form a valid range.
For example, "[i-S]" in a filename will crash.
Given that this check is meant to be searching for existing items, not actually applying a regular expression, I've used
quotemeta
on the whole filename.