From fa6158ba02fe6d8384e866f8a9dfb2adf2ad1e61 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Thu, 25 Dec 2014 19:43:23 -0600 Subject: [PATCH] fix for someone sending weird URI requests periodically --- app/blog.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/blog.rb b/app/blog.rb index 606622a3..3d593485 100644 --- a/app/blog.rb +++ b/app/blog.rb @@ -8,5 +8,15 @@ end get '/blog/:article' do |article| expires 500, :public, :must_revalidate - return Net::HTTP.get_response(URI("http://blog.neocities.org/#{article}.html")).body + + attempted = false + + begin + return Net::HTTP.get_response(URI("http://blog.neocities.org/#{article}.html")).body + rescue => e + raise e if attempted + attempted = true + article = article.match(/^[a-zA-Z0-9-]+/).to_s + retry + end end \ No newline at end of file