Skip to content

Commit dcdc3d8

Browse files
committed
Sanitize lat/lon for SQL query.
1 parent 1ff64c4 commit dcdc3d8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/geocoder/sql.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ def approx_distance(latitude, longitude, lat_attr, lon_attr, options = {})
4444
end
4545

4646
def within_bounding_box(sw_lat, sw_lng, ne_lat, ne_lng, lat_attr, lon_attr)
47-
spans = "#{lat_attr} BETWEEN #{sw_lat} AND #{ne_lat} AND "
47+
spans = "#{lat_attr} BETWEEN #{sw_lat.to_f} AND #{ne_lat.to_f} AND "
4848
# handle box that spans 180 longitude
4949
if sw_lng.to_f > ne_lng.to_f
50-
spans + "(#{lon_attr} BETWEEN #{sw_lng} AND 180 OR " +
51-
"#{lon_attr} BETWEEN -180 AND #{ne_lng})"
50+
spans + "(#{lon_attr} BETWEEN #{sw_lng.to_f} AND 180 OR " +
51+
"#{lon_attr} BETWEEN -180 AND #{ne_lng.to_f})"
5252
else
53-
spans + "#{lon_attr} BETWEEN #{sw_lng} AND #{ne_lng}"
53+
spans + "#{lon_attr} BETWEEN #{sw_lng.to_f} AND #{ne_lng.to_f}"
5454
end
5555
end
5656

0 commit comments

Comments
 (0)