diff --git a/lib/misc/allowed_chars.txt b/lib/misc/allowed_chars.txt new file mode 100644 index 0000000..e3f4880 --- /dev/null +++ b/lib/misc/allowed_chars.txt @@ -0,0 +1 @@ +abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ÄÖÜäöüß&*$% ':?,-(+.)/ diff --git a/lib/sepa_king/converter.rb b/lib/sepa_king/converter.rb index 4141964..9f345d3 100644 --- a/lib/sepa_king/converter.rb +++ b/lib/sepa_king/converter.rb @@ -15,6 +15,8 @@ def convert(*attributes, options) end module InstanceMethods + ALLOWED_CHARS = Regexp.escape(File.read('lib/misc/allowed_chars.txt')).freeze + def convert_text(value) return unless value @@ -29,7 +31,7 @@ def convert_text(value) gsub(/\n+/,' '). # Remove all invalid characters - gsub(/[^a-zA-Z0-9ÄÖÜäöüß&*$%\ \'\:\?\,\-\(\+\.\)\/]/, ''). + gsub(/[^#{ALLOWED_CHARS}]/, ''). # Remove leading and trailing spaces strip