diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-16 01:06:51 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2010-10-16 01:06:51 -0700 |
commit | 46a0bb7b5efb106603fc3a6048b6bae211007bfb (patch) | |
tree | 6d9e7f8f6c21c1c86ebaf2b25710703210a283d2 | |
parent | e6adaf866920ee414bdf732047859d74991e1cb9 (diff) | |
download | omptagger-46a0bb7b5efb106603fc3a6048b6bae211007bfb.tar.gz omptagger-46a0bb7b5efb106603fc3a6048b6bae211007bfb.tar.xz |
Force user to follow Vorbis comment specification.
-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 |