From 200fa557e11cff95a8e3c3b9e136124bb8801f98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 9 May 2012 15:02:54 +0200 Subject: Particle: add_dsts raise Exception on malformed dst --- lib/evendoors/particle.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/evendoors/particle.rb b/lib/evendoors/particle.rb index 82b3983..111ce9a 100644 --- a/lib/evendoors/particle.rb +++ b/lib/evendoors/particle.rb @@ -43,18 +43,19 @@ module EvenDoors @dsts.clear end # - def add_dsts paths - paths.split(EvenDoors::LINK_SEP).each do |path| - d = path.sub(/^\/+/,'').sub(/\/+$/,'').gsub(/\/{2,}/,'/').gsub(/\s+/,'') - next if d.empty? or d==EvenDoors::ACT_SEP - @dsts << d + def add_dsts dsts + dsts.split(EvenDoors::LINK_SEP).each do |dst| + if dst.empty? or dst[0]==EvenDoors::PATH_SEP or dst[0]==EvenDoors::PATH_SEP or dst=~/\/\?/\ + or dst=~/\/{2,}/ or dst=~/\s+/ or dst==EvenDoors::ACT_SEP + raise EvenDoors::Exception.new "destination #{dst} is not acceptable" + end + @dsts << dst end end # def set_dst! a, d='' @dst = @room = @door = @action = nil clear_dsts! - return if ( (a.nil? or a.empty?) and d.empty? ) add_dsts d+EvenDoors::ACT_SEP+a end # -- cgit v1.1-2-g2b99