summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-16 01:06:51 -0700
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2010-10-16 01:06:51 -0700
commit46a0bb7b5efb106603fc3a6048b6bae211007bfb (patch)
tree6d9e7f8f6c21c1c86ebaf2b25710703210a283d2
parente6adaf866920ee414bdf732047859d74991e1cb9 (diff)
downloadomptagger-46a0bb7b5efb106603fc3a6048b6bae211007bfb.tar.gz
omptagger-46a0bb7b5efb106603fc3a6048b6bae211007bfb.tar.xz
Force user to follow Vorbis comment specification.
-rwxr-xr-xomptagger24
1 files changed, 24 insertions, 0 deletions
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