diff options
-rwxr-xr-x | omptagger | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -118,6 +118,12 @@ class Metadata def addtag(field, value) puts ('Adding ' + field + ' tag:').format(:action) + unless valid_field?(field) + puts 'Invalid field name.'.format(:info) + puts 'See Vorbis comment specification.'.format(:info) + throw :next + end + field.upcase! if @tags.has_key?(field) @@ -134,6 +140,12 @@ class Metadata def settag(field, value) puts ('Setting ' + field + ' tag:').format(:action) + unless valid_field?(field) + puts 'Invalid field name.'.format(:info) + puts 'See Vorbis comment specification.'.format(:info) + throw :next + end + field.upcase! @tags[field] = [value] @@ -161,6 +173,18 @@ class VorbisComment < Metadata @file.save end + + def valid_field?(field) + valid = (32..125).collect do |character| + character.chr + end + + field.scan(/./).each do |character| + return false unless valid.include?(character) + end + + return true + end end class FLAC < VorbisComment |