From 9fe1551a8db1af32eb1f8c99538a0bc60df7be72 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Sun, 6 Sep 2009 10:56:20 -0400 Subject: [PATCH] coerce Message#add_label (and others) arguments to symbols So that hook authors can't destroy their index by adding a string as a label. --- lib/sup/message.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/sup/message.rb b/lib/sup/message.rb index f640011..4a7d761 100644 --- a/lib/sup/message.rb +++ b/lib/sup/message.rb @@ -191,11 +191,13 @@ class Message def has_label? t; @labels.member? t; end def add_label l + l = l.to_sym return if @labels.member? l @labels << l @dirty = true end def remove_label l + l = l.to_sym return unless @labels.member? l @labels.delete l @dirty = true @@ -207,6 +209,7 @@ class Message def labels= l raise ArgumentError, "not a set" unless l.is_a?(Set) + raise ArgumentError, "not a set of labels" unless l.all? { |ll| ll.is_a?(Symbol) } return if @labels == l @labels = l @dirty = true -- 2.43.0