display 'not found' when a bad password is given in URL
authorLunar <lunar@anargeek.net>
Fri, 16 Mar 2012 19:13:17 +0000 (20:13 +0100)
committerLunar <lunar@anargeek.net>
Fri, 23 Mar 2012 17:11:28 +0000 (18:11 +0100)
lib/coquelicot/app.rb
spec/coquelicot_spec.rb

index 961c5b4..dfd7ddd 100644 (file)
@@ -189,7 +189,11 @@ module Coquelicot
 
       link = Coquelicot.remap_base32_extra_characters(link)
       pass = Coquelicot.remap_base32_extra_characters(pass)
-      not_found unless send_link(link, pass)
+      begin
+        not_found unless send_link(link, pass)
+      rescue Coquelicot::BadKey
+        not_found
+      end
     end
 
     get '/:link' do |link|
index f39518c..f8bcb10 100644 (file)
@@ -105,6 +105,11 @@ describe 'Coquelicot' do
         url_name.split('-').should have(2).items
       end
 
+      it "should say 'not found' is password in URL is wrong" do
+        get "#{@url}wrong"
+        last_response.status.should == 404
+      end
+
       it "should download when using extra Base32 characters in URL" do
         splitted = @url.split('/')
         name = splitted[-1].upcase.gsub(/O/, '0').gsub(/L/, '1')