cartodb-4.42/lib/carto/file_system/sanitize.rb
2024-04-06 05:25:13 +00:00

17 lines
535 B
Ruby

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