Changeset 7088 for platform/tdiary/util

Show
Ignore:
Timestamp:
02/24/08 12:08:32 (9 months ago)
Author:
drry
Message:

platform/tdiary/util/posttdiary/posttdiary.rb:

  • i've made a mistake about the "case" statement in changeset:7079.
  • backouted some indents to previous coding style.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • platform/tdiary/util/posttdiary/posttdiary.rb

    r7080 r7088  
    6868        use_subject = false 
    6969        parser.set_options( 
    70                 ['--image-path',   '-i', GetoptLong::REQUIRED_ARGUMENT], 
    71                 ['--image-url',    '-u', GetoptLong::REQUIRED_ARGUMENT], 
     70                ['--image-path', '-i', GetoptLong::REQUIRED_ARGUMENT], 
     71                ['--image-url', '-u', GetoptLong::REQUIRED_ARGUMENT], 
    7272                ['--image-format', '-f', GetoptLong::REQUIRED_ARGUMENT], 
    73                 ['--use-subject',  '-s', GetoptLong::NO_ARGUMENT] 
     73                ['--use-subject', '-s', GetoptLong::NO_ARGUMENT] 
    7474        ) 
    7575        begin 
     
    9393        image_url.sub!( %r[/*$], '/' ) if image_url 
    9494        url = ARGV.shift 
    95         if %r|http://([^:/]*):?(\d*)(/.*)| =~ url then 
     95        if %r|http://([^:/]+)(?::(\d+))?(/.*)| =~ url then 
    9696                host = $1 
    97                 port = $2.to_i 
    98                 cgi = $3 
    99                 raise 'bad url.' if not host or not cgi 
    100                 port = 80 if port == 0 
     97                port = ($2 || 80).to_i 
     98                cgi  = $3 
    10199        else 
    102100                raise 'bad url.' 
     
    134132                                name=".+(\.[^.]+?)" (?# 1: extension) 
    135133                        ]imx 
    136                                 image_ext  = $1.downcase 
    137                                 now        = Time::now 
    138                                 list       = image_list( now.strftime( "%Y%m%d" ), image_dir ) 
     134                                image_ext = $1.downcase 
     135                                now = Time::now 
     136                                list = image_list( now.strftime( "%Y%m%d" ), image_dir ) 
    139137                                image_name = now.strftime( "%Y%m%d" ) + "_" + list.length.to_s + image_ext 
    140138                                File::umask( 022 ) 
     
    176174        if /^To:(.*)$/ =~ head then 
    177175                addr = case to = $1.strip 
    178                 when /.*?\s*<(.+)>/ 
    179                 when /(.+?)\s*\(.*\)/ 
     176                when /.*?\s*<(.+)>/, /(.+?)\s*\(.*\)/ 
    180177                        $1 
    181178                else 
     
    227224                res, = http.get( cgi, { 
    228225                                'Authorization' => "Basic #{auth}", 
    229                                 'Referer'       => url }) 
     226                                'Referer' => url }) 
    230227                if %r|<input type="hidden" name="csrf_protection_key" value="([^"]+)">| =~ res.body then 
    231228                        data << "&csrf_protection_key=#{CGI::escape( CGI::unescapeHTML( $1 ) )}" 
     
    233230                res, = http.post( cgi, data, { 
    234231                                'Authorization' => "Basic #{auth}", 
    235                                 'Referer'       => url }) 
     232                                'Referer' => url }) 
    236233        end 
    237234