]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/amf_controller.rb
Fixed error handling in the name search and tidied things up a bit.
[rails.git] / app / controllers / amf_controller.rb
index 72f1dd74eb9bed75047aa2beacdf6c2cb90baaaf..18a1c63469b6ce91c1a04c31b370552af1e9cb3c 100644 (file)
@@ -33,8 +33,6 @@ class AmfController < ApplicationController
       bytes=getlong(req)                               #  | get total size in bytes
       args=getvalue(req)                               #  | get response (probably an array)
 
-      RAILS_DEFAULT_LOGGER.info("  Message: #{message}")
-
       case message
                  when 'getpresets';    results[index]=putdata(index,getpresets)
                  when 'whichways';             results[index]=putdata(index,whichways(args))
@@ -48,12 +46,10 @@ class AmfController < ApplicationController
     # Write out response
 
     RAILS_DEFAULT_LOGGER.info("  Response: start")
-    response.headers["Content-Type"]="application/x-amf"
     a,b=results.length.divmod(256)
-       render :text => proc { |response, output| 
+       render :content_type => "application/x-amf", :text => proc { |response, output| 
         output.write 0.chr+0.chr+0.chr+0.chr+a.chr+b.chr
                results.each do |k,v|
-                 RAILS_DEFAULT_LOGGER.info("  Response: encode #{k}")
                  output.write(v)
                end
        }
@@ -292,6 +288,7 @@ EOF
       ymin=[ys,ymin].min; ymax=[ys,ymax].max
       node=points[i][2].to_i
       tagstr=array2tag(points[i][4])
+         tagstr=tagstr.gsub(/[\000-\037]/,"")
       tagsql="'"+sqlescape(tagstr)+"'"
 
       # compare node
@@ -404,10 +401,12 @@ EOF
     insertsql =''
     currentsql=''
     attributes.each do |k,v|
-      if v=='' then next end
+      if v=='' or v.nil? then next end
       if v[0,6]=='(type ' then next end
       if insertsql !='' then insertsql +=',' end
       if currentsql!='' then currentsql+=',' end
+         k=k.gsub(/[\000-\037]/,"")
+         v=v.gsub(/[\000-\037]/,"")
       insertsql +="(#{way},'"+sqlescape(k)+"','"+sqlescape(v)+"',#{version})"
       currentsql+="(#{way},'"+sqlescape(k)+"','"+sqlescape(v)+"')"
     end