Changeset 2867 for lang/ruby/ssb

Show
Ignore:
Timestamp:
12/08/07 17:20:07 (13 months ago)
Author:
coji
Message:

lang/ruby/ssb: fix some bugs. use WEBrick::HTTPUtils instaed of CGI.encode, form regexp

Location:
lang/ruby/ssb/trunk/libs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/ssb/trunk/libs/ssb.rb

    r2826 r2867  
    152152 
    153153      # form action と a href と img src のURLを書き換え 
    154       page = page.gsub(/ (action|href|src|data)[ ]*=[ ]*[\"']?([^>\"' ]+)[\"']?([^>]*)>/im) { |s| 
     154      page = page.gsub(/ (action|href|src|data)\s*=\s*[\"']?([^>\"'\s]+)[\"']?([^>]*)>/im) { |s| 
    155155        begin 
    156156          tag = $1.downcase 
     
    161161              %Q! #{tag}="#{$2}"#{$3} target="_top" >! 
    162162            when '/' 
    163               %Q! #{tag}="./?ssb_q=#{CGI.escape(('http://' + request_uri.host + ':' + request_uri.port.to_s + $2).to_s)}"#{$3} target="_top" >! 
     163              %Q! #{tag}="./?ssb_q=#{WEBrick::HTTPUtils.escape_form(('http://' + request_uri.host + ':' + request_uri.port.to_s + $2).to_s)}"#{$3} target="_top" >! 
    164164            else 
    165               %Q! #{tag}="./?ssb_q=#{CGI.escape((request_uri + $2).to_s)}"#{$3} target="_top" >! 
     165              %Q! #{tag}="./?ssb_q=#{WEBrick::HTTPUtils.escape_form((request_uri + $2).to_s)}"#{$3} target="_top" >! 
    166166            end 
    167167          when 'action' 
     
    174174 
    175175      # xx-small/xx-large を手加減 
    176       page.gsub!(/xx-small/im,'small') 
     176      page.gsub!(/xx-small/im, 'small') 
    177177      page.gsub!(/xx-large/im, 'large') 
    178178      # 絵文字を <img> に変換 
  • lang/ruby/ssb/trunk/libs/ssb/request.rb

    r2828 r2867  
    5454 
    5555    def execute 
     56      return nil if @uri.to_s == 'about:blank' 
     57 
    5658      response = nil 
    57       return nil if @uri.scheme == 'about' 
    58  
    5959      http = http_class(@http_proxy).new(@uri.host, @uri.port) 
    6060      if @uri.scheme == 'https' 
     
    8989        else 
    9090          uri_params << in_query[key].list.map do |value| 
    91             "#{NKF::nkf('-s', key.dup.untaint)}=#{CGI.escape(NKF::nkf('-s', value.dup.untaint))}" 
     91            "#{NKF::nkf('-s', key.dup.untaint)}=#{WEBrick::HTTPUtils.escape(NKF::nkf('-s', value.dup.untaint))}" 
    9292          end 
    9393        end