1. 22 9月, 2020 1 次提交
    • A
      Catch invalid UTF-8 encodings on ActionDispatch::Http::Request#POST (#40124) · 7dc53ec9
      Adrianna Chang 提交于
      * Add binary encoding logic into ActionDispatch::Request::Utils
      
      Moving the logic to set binary encoding into ActionDispatch::Request::Utils
      will allow us to encode from GET and POST in ActionDispatch::Request.
      
      * Refactor binary encoding logic
      
      - Move binary encoding calls into GET, POST and path_parameters
      - Remove binary encoding from ActionDispatch::Http::Request
      - This way, we only raise an invalid encoding exception if the controller is not requesting
      parameters in binary encoding
      
      * Check if encoding is valid in ActionDispatch::Request#POST and raise BadRequest if invalid
      
      * Fix multipart_params_test that has binary-encoded params containing invalid UTF-8 characters
      
      * Address PR comments
      
      * Pass action and controller to Request::Utils.set_binary_encoding
      
      [Rafael Mendonça França + Adrianna Chang]
      7dc53ec9
  2. 06 9月, 2020 1 次提交
    • P
      Shorten inspect on ActionDispatch::Request · a610f61e
      Petrik 提交于
      Calling request in an action of a controller generates an endless stream of
      characters, including the Rack app and middlewares.
      This can be frustrating when using a debugger in a controller and
      accidentally calling `request` generates output for a couple of seconds.
      
      Inspect on ActionDispatch::Request is shortened to the most relevant
      attributes and uses the same format as used for request in the logs:
      
          "#<ActionDispatch::Request POST "https://example.com/path/of/some/uri?q=1" for 1.2.3.4>"
      a610f61e
  3. 14 6月, 2020 1 次提交
  4. 26 5月, 2020 1 次提交
  5. 10 3月, 2020 1 次提交
  6. 25 2月, 2020 1 次提交
  7. 09 12月, 2019 1 次提交
  8. 04 12月, 2019 1 次提交
    • J
      Distinguish missing controller exceptions from unrelated NameError · 54878cd4
      Jean Boussier 提交于
      Fix: https://github.com/rails/rails/issues/37650
      
      The classic autoloader used to totally unregister any constant that
      failed midway. Which mean `"SomeConst".constantize` was idempotent.
      
      However Zeitwerk rely on normal `Kernel#require` behavior, which mean
      that if an exception is raised during a class/module definition,
      it will be left incompletely defined. For instance:
      
      ```ruby
      class FooController
        ::DoesNotExist
      
        def index
        end
      end
      ```
      
      Will leave `FooController` defined, but without its `index` method.
      
      Because of this, when silencing a NameError, it's important
      to make sure the missing constant is really the one we were trying
      to load.
      54878cd4
  9. 07 11月, 2019 1 次提交
  10. 03 11月, 2019 1 次提交
  11. 07 10月, 2019 1 次提交
    • N
      Updated `ActionDispatch::Request.remote_ip=` · bf14a8e2
      norm 提交于
      Updated the setter to clear the value in the `@remote_ip` instance
      variable before setting the header that the value is derived from in the
      getter.
      bf14a8e2
  12. 31 7月, 2019 1 次提交
  13. 29 7月, 2019 1 次提交
  14. 11 7月, 2019 1 次提交
  15. 14 11月, 2018 1 次提交
  16. 29 9月, 2018 1 次提交
    • Y
      Add `Style/RedundantFreeze` to remove redudant `.freeze` · aa3dcabd
      Yasuo Honda 提交于
      Since Rails 6.0 will support Ruby 2.4.1 or higher
      `# frozen_string_literal: true` magic comment is enough to make string object frozen.
      This magic comment is enabled by `Style/FrozenStringLiteralComment` cop.
      
      * Exclude these files not to auto correct false positive `Regexp#freeze`
       - 'actionpack/lib/action_dispatch/journey/router/utils.rb'
       - 'activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb'
      
      It has been fixed by https://github.com/rubocop-hq/rubocop/pull/6333
      Once the newer version of RuboCop released and available at Code Climate these exclude entries should be removed.
      
      * Replace `String#freeze` with `String#-@` manually if explicit frozen string objects are required
      
       - 'actionpack/test/controller/test_case_test.rb'
       - 'activemodel/test/cases/type/string_test.rb'
       - 'activesupport/lib/active_support/core_ext/string/strip.rb'
       - 'activesupport/test/core_ext/string_ext_test.rb'
       - 'railties/test/generators/actions_test.rb'
      aa3dcabd
  17. 27 11月, 2017 1 次提交
  18. 02 11月, 2017 1 次提交
  19. 21 10月, 2017 1 次提交
  20. 04 10月, 2017 1 次提交
    • E
      Implement H2 Early Hints for Rails · 59a02fb7
      eileencodes 提交于
      When puma/puma#1403 is merged Puma will support the Early Hints status
      code for sending assets before a request has finished.
      
      While the Early Hints spec is still in draft, this PR prepares Rails to
      allowing this status code.
      
      If the proxy server supports Early Hints, it will send H2 pushes to the
      client.
      
      This PR adds a method for setting Early Hints Link headers via Rails,
      and also automatically sends Early Hints if supported from the
      `stylesheet_link_tag` and the `javascript_include_tag`.
      
      Once puma supports Early Hints the `--early-hints` argument can be
      passed to the server to enable this or set in the puma config with
      `early_hints(true)`. Note that for Early Hints to work
      in the browser the requirements are 1) a proxy that can handle H2,
      and 2) HTTPS.
      
      To start the server with Early Hints enabled pass `--early-hints` to
      `rails s`.
      
      This has been verified to work with h2o, Puma, and Rails with Chrome.
      
      The commit adds a new option to the rails server to enable early hints
      for Puma.
      
      Early Hints spec:
      https://tools.ietf.org/html/draft-ietf-httpbis-early-hints-04
      
      [Eileen M. Uchitelle, Aaron Patterson]
      59a02fb7
  21. 22 8月, 2017 1 次提交
  22. 02 8月, 2017 1 次提交
    • E
      Path parameters should default to UTF8 · 92209356
      eileencodes 提交于
      This commit changes the behavior such the path_params now default to
      UTF8 just like regular parameters. This also changes the behavior such
      that if a path parameter contains invalid UTF8 it returns a 400 bad
      request. Previously the behavior was to encode the path params as binary
      but that's not the same as query params.
      
      So this commit makes path params behave the same as query params.
      
      It's important to test with a path that's encoded as binary because
      that's how paths are encoded from the socket. The test that was altered
      was changed to make the behavior for bad encoding the same as query
      params. We want to treat path params the same as query params. The params
      in the test are invalid UTF8 so they should return a bad request.
      
      Fixes #29669
      
      *Eileen M. Uchitelle, Aaron Patterson, & Tsukuru Tanimichi*
      92209356
  23. 25 7月, 2017 1 次提交
  24. 11 7月, 2017 1 次提交
  25. 07 7月, 2017 1 次提交
  26. 02 7月, 2017 1 次提交
  27. 01 7月, 2017 2 次提交
  28. 14 3月, 2017 1 次提交
  29. 29 12月, 2016 2 次提交
    • 415e17d0
    • S
      Update request.rb --ci skip · 0a64fb27
      Shardul Parab 提交于
      Documentation for ActionDispatch::Request#key? [ci skip]
      
      Update request.rb --ci skip
      
      Documentation for ActionDispatch::Request#key? [ci skip]
      Also made change after the  review by @rafaelfranca .
      
      Update request.rb --ci skip
      
      Documentation for ActionDispatch::Request#key? [ci skip]
      Also made change after the  review by @rafaelfranca .
      
      Update request.rb --ci skip
      0a64fb27
  30. 22 12月, 2016 1 次提交
    • A
      Document and update API for `skip_parameter_encoding` · 2eb0a663
      Aaron Patterson 提交于
      This commit changes `parameter_encoding` to `skip_parameter_encoding`.
      `skip_parameter_encoding` will set encoding on all parameters to
      ASCII-8BIT for a given action on a particular controller.  This allows
      the controller to handle data when the encoding of that data is unknown,
      for example file systems or truly binary parameters.
      2eb0a663
  31. 10 10月, 2016 1 次提交
  32. 16 8月, 2016 1 次提交
  33. 10 8月, 2016 1 次提交
  34. 07 8月, 2016 1 次提交
  35. 14 7月, 2016 1 次提交
    • G
      Check `request.path_parameters` encoding at the point they're set · 9f38a3fb
      Grey Baker 提交于
      Check for any non-UTF8 characters in path parameters at the point they're
      set in `env`. Previously they were checked for when used to get a controller
      class, but this meant routes that went directly to a Rack app, or skipped
      controller instantiation for some other reason, had to defend against
      non-UTF8 characters themselves.
      9f38a3fb
  36. 20 3月, 2016 1 次提交
    • J
      Fix request.reset_session for API controllers · 6c6a2217
      Jon Moss 提交于
      Due to that `ActionDispatch::Flash` (the flash API's middleware) is not
      included for API controllers, the `request.reset_session` method, which
      relies on there being a `flash=` method which is in fact defined by the
      middleware, was previously breaking. Similarly to how
      add46482 created a method to be
      overridden by the flash middleware in order to ensure non-breakage, this
      is how flashes are now reset.
      
      Fixes #24222
      6c6a2217
  37. 24 2月, 2016 1 次提交
  38. 14 1月, 2016 1 次提交
    • A
      Space Oddity · d9bdb611
      Akira Matsuda 提交于
      Converting nbsp(\u{00A0}) to the normal ASCII space(\u{0020})
      [ci skip]
      d9bdb611