You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
535 B

4 years ago
module Carto
module FileSystem
module Sanitize
# Sanitize: NUL, slash, backslash, colon, asterisk, question, quote, less, greater, pipe
DISALLOWED_CHARACTERS = /[\x00\/\\:\*\?\"<>\|]/
def self.sanitize_identifier(identifier, replacement_character: '_')
if replacement_character =~ DISALLOWED_CHARACTERS
raise "Unsafe replacement character '#{replacement_character}'"
else
identifier.gsub(DISALLOWED_CHARACTERS, replacement_character)
end
end
end
end
end