summaryrefslogtreecommitdiff
path: root/omptagger
diff options
context:
space:
mode:
Diffstat (limited to 'omptagger')
-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