Escape names passed to ws.geonames.org as part of the URL.
authorTom Hughes <tom@compton.nu>
Thu, 19 Jul 2007 15:14:34 +0000 (15:14 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 19 Jul 2007 15:14:34 +0000 (15:14 +0000)
app/controllers/geocoder_controller.rb

index 76b157faabd6058f2c536711dc49942115939416..4ce31baf4da099dd1d1e61cbbb502efa5ec37e51 100644 (file)
@@ -1,6 +1,7 @@
 class GeocoderController < ApplicationController
   layout 'site'
 
+  require 'uri'
   require 'net/http'
   require 'rexml/document'
 
@@ -110,7 +111,7 @@ class GeocoderController < ApplicationController
     @res_ary = []
     begin
       Net::HTTP.start('ws.geonames.org') do |http|
-        res = http.get("/search?q=#{@place_name}&maxRows=10")
+        res = http.get("/search?q=#{URI.escape(@place_name)}&maxRows=10")
         xml = REXML::Document.new(res.body)
         xml.elements.each("geonames/geoname") do |ele|
           res_hash = {}