From 46a0bb7b5efb106603fc3a6048b6bae211007bfb Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Sat, 16 Oct 2010 01:06:51 -0700 Subject: Force user to follow Vorbis comment specification. --- omptagger | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'omptagger') diff --git a/omptagger b/omptagger index 074c4fb..e57a229 100755 --- a/omptagger +++ b/omptagger @@ -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 -- cgit v1.2.3-70-g09d2