Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove Timeout block from geocode endpoint for being generally unsafe.

The timeout can happen elsewhere (e.g. Unicorn or Gate).
  • Loading branch information...
commit b681fd70d948e21ccafea184e790f81c889ea813 1 parent 9e3bd5b
Schuyler Erle authored
Showing with 1 addition and 12 deletions.
  1. +1 −12 lib/geocoder/us/rest.rb
View
13 lib/geocoder/us/rest.rb
@@ -1,24 +1,13 @@
require 'sinatra'
require 'geocoder/us/database'
require 'json'
-require 'timeout'
@@db = Geocoder::US::Database.new(ARGV[0] || ENV["GEOCODER_DB"])
set :port, 8081
get '/geocode' do
if params[:q]
- results = []
- begin
- # TODO: remove this Timeout call?
- # Read this blog post to see why Timeout is very dangerous:
- # http://blog.headius.com/2008/02/ruby-threadraise-threadkill-timeoutrb.html
- Timeout.timeout(1.0) do
- results = @@db.geocode params[:q]
- end
- rescue Timeout::Error
- $stderr.print "Timed out on '#{params[:q]}'\n"
- end
+ results = @@db.geocode params[:q]
features = []
results.each do |result|
coords = [result.delete(:lon), result.delete(:lat)]
Please sign in to comment.
Something went wrong with that request. Please try again.