Changeset 1049

Show
Ignore:
Timestamp:
11/25/07 17:48:43 (1 year ago)
Author:
e.@brainspl.at
Message:

fix error when multipart parsing fails and exception controller tries to do it again and fails. Now it will be caught the first time and proper stack trace is shown.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/merb/exceptions.rb

    r975 r1049  
    137137    class ClientError                   < Merb::ControllerExceptions::Base; end 
    138138      class BadRequest                  < Merb::ControllerExceptions::ClientError; STATUS = 400; end 
     139        class MultiPartParseError       < Merb::ControllerExceptions::BadRequest; end 
    139140      class Unauthorized                < Merb::ControllerExceptions::ClientError; STATUS = 401; end 
    140141      class PaymentRequired             < Merb::ControllerExceptions::ClientError; STATUS = 402; end 
  • trunk/lib/merb/mixins/controller.rb

    r895 r1049  
    228228      MERB_LOGGER.info("Redirecting to: #{url}") 
    229229      set_status(302) 
    230       headers.merge!({'Location'=> url}) 
    231       return '' 
     230      headers['Location'] = url 
     231      "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>" 
    232232    end 
    233233     
  • trunk/lib/merb/request.rb

    r1042 r1049  
    7171     
    7272    def multipart_params 
    73       @multipart_params ||= begin 
    74         if Merb::Const::MULTIPART_REGEXP =~ content_type 
    75           self.class.parse_multipart(@body, $1, content_length) 
    76         end 
    77       end 
     73      @multipart_params ||=  
     74        begin 
     75          if Merb::Const::MULTIPART_REGEXP =~ content_type 
     76            self.class.parse_multipart(@body, $1, content_length) 
     77          end 
     78        rescue ControllerExceptions::MultiPartParseError => e 
     79          @multipart_params = {} 
     80          raise e 
     81        end 
    7882    end 
    7983     
     
    335339        content_length -= boundary_size 
    336340        status = input.read(boundary_size) 
    337         raise EOFError, "bad content body"  unless status == boundary + EOL 
     341        raise ControllerExceptions::MultiPartParseError, "bad content body:\n'#{status}' should == '#{boundary + EOL}'"  unless status == boundary + EOL 
    338342        rx = /(?:#{EOL})?#{Regexp.quote(boundary,'n')}(#{EOL}|--)/ 
    339343        loop { 
     
    370374            if( read_size > 0 ) 
    371375              c = input.read(read_size) 
    372               raise EOFError, "bad content body"  if c.nil? || c.empty? 
     376              raise ControllerExceptions::MultiPartParseError, "bad content body"  if c.nil? || c.empty? 
    373377              buf << c 
    374378              content_length -= c.size