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. 16 9月, 2020 4 次提交
  3. 06 9月, 2020 2 次提交
    • P
      Shorten inspect on AbstractController::Base · 080edb44
      Petrik 提交于
      Calling self in an action of a controller generates an endless stream of
      characters, including the request object and all instances variables.
      This can be frustrating when using a debugger in a controller and
      accidentally calling `self` generates output for a couple of seconds.
      
      This shortens inspect to only show the class name.
      
          MyController.new.inspect # => "#<MyController:0x00000000005028>"
      080edb44
    • 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
  4. 31 8月, 2020 1 次提交
  5. 26 8月, 2020 1 次提交
  6. 11 8月, 2020 1 次提交
  7. 28 7月, 2020 1 次提交
    • D
      Move Path::Pattern factories into test helper · 8eec6ee9
      Daniel Colson 提交于
      `Pattern#from_sting` was introduced in bb207ea7 to support creating
      patterns from strings in tests (removing a conditional in the initialize
      method that had been there only for the sake of those tests).
      
      `Pattern#build` was introduced in 947ebe9a, and was similarly used only
      in tests.
      
      My understanding is that [`Mapping#path`][path] is the only place where
      we initialize a `Path::Pattern` in library code.
      
      Since these two methods appear to be used only in tests, this
      commit moves them out of the class and into a test helper.
      
      My reasoning for doing this is that I am doing some performance work
      that may involve a modification to how `Path::Pattern`s get initialized,
      and I will have more confidence in that work if I know for sure that
      these methods are test helpers that can be modified freely.
      
      [path]: https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/routing/mapper.rb#L192-L194
      8eec6ee9
  8. 26 7月, 2020 1 次提交
  9. 21 7月, 2020 1 次提交
  10. 20 7月, 2020 1 次提交
  11. 15 7月, 2020 1 次提交
  12. 06 7月, 2020 1 次提交
  13. 01 7月, 2020 1 次提交
  14. 30 6月, 2020 1 次提交
  15. 19 6月, 2020 1 次提交
    • E
      Fix json encoded controller tests · 9540a7b1
      eileencodes 提交于
      The controller test case is trying to encode json parameters in the same
      way it encodes query parameters. However we need to encode json
      parameters as json.
      
      This was broken in #39534 because `generate_extras` is encoding
      everything into query parameters. But json parameters are in the post
      body and need to be treated differently than the query parameters.
      
      Followup to #39651
      
      Aaron Patterson <tenderlove@ruby-lang.org>
      9540a7b1
  16. 18 6月, 2020 1 次提交
  17. 17 6月, 2020 1 次提交
  18. 16 6月, 2020 1 次提交
    • E
      Fix route params using reserved keywords: · 7dc4c436
      Edouard CHIN 提交于
      - In #39534, `Routing::RouteSet#generate_extras` (which get called)
        by ActionController::TestCase now go through `path_for` which strips
        out all key in the options hash that have the same name as the ones
        defined in `RESERVED_OPTIONS`.
      7dc4c436
  19. 14 6月, 2020 1 次提交
  20. 11 6月, 2020 1 次提交
  21. 10 6月, 2020 1 次提交
    • J
      Strict match when choosing cookie domain for host · 1704be74
      Jonathan Hefner 提交于
      Prior to this commit, when multiple cookie domains were specified, the
      first domain that was a substring of the request host was chosen.  This
      allowed, for example, the "example.com" domain to be chosen when the
      request host was "example.com.au" or even "myexample.com".
      
      This commit ensures a domain is chosen only if it is equal to or is a
      superdomain of the request host.
      
      Fixes #37760.
      1704be74
  22. 06 6月, 2020 1 次提交
    • E
      Convert route params array into object · 437ab203
      eileencodes 提交于
      This PR converts the route params array into an object and moves the
      error generation code into its own object as well. This is a refactoring
      of internal code to make it easier to change and simplier for internals
      to interface with. We have two new objects:
      
      1) `RouteWithParams`
      
      Previously `#generate` returned an array of parameterized parts for a
      route. We have now turned this into an object with a `path` and a
      `params methods` to be able to access the parts we need.
      
      2) `MissingRoute`
      
      `#generate` was also responsible for constructing the message for the
      error. We've moved this code into the new `MissingRoute` object so it
      does that work instead.
      
      This change makes these methods reusable throughout the code and easier
      for future refactoring we plan to do.
      Co-authored-by: NAaron Patterson <aaron.patterson@gmail.com>
      437ab203
  23. 01 6月, 2020 1 次提交
    • R
      Allow rails to serve brotli encoded assets · 3d9a98b4
      Ryan Hall 提交于
      When using an external build process (webpack, grunt) it's helpful for
      rails to be able to serve those assets. Brotli has better compression
      than gzip and should eventually replace it for static assets.
      
      When using an external build process (webpack, grunt) it's helpful for
      rails to be able to serve those assets. Brotli has better compression
      than gzip and will eventually replace it for static assets.
      3d9a98b4
  24. 30 5月, 2020 1 次提交
  25. 28 5月, 2020 1 次提交
  26. 24 5月, 2020 1 次提交
  27. 23 5月, 2020 1 次提交
  28. 21 5月, 2020 1 次提交
  29. 20 5月, 2020 4 次提交
    • J
      Satisfy Rubocop · 2037185e
      Jonathan Hefner 提交于
      Fixes offense:
      
      ```
      actionpack/test/journey/router_test.rb:493:37: C: Style/HashSyntax: Use the new Ruby 1.9 hash syntax.
                  options = options.merge(:_recall => recall)
                                          ^^^^^^^^^^^
      ```
      2037185e
    • A
      Move tests higher up the stack · c34b6b09
      Aaron Patterson 提交于
      Journey is considered internal, and I would like to stop testing
      internals so that we are free to refactor.  This commit just moves us up
      one more call frame with the goal if getting closer to a public API.
      Once we're up the stack high enough that we're testing a public API we
      can stop
      c34b6b09
    • F
      6c4f3be9
    • E
      Stop calling methods directly on Journey · 58cf1a5f
      eileencodes 提交于
      Journey is a private API that we want to refactor. We need to stop
      calling methods directly on it so we're free to change the
      implmentation.
      58cf1a5f
  30. 19 5月, 2020 2 次提交
    • P
      Add DidYouMean for ParameterMissing · 5411565d
      Petrik 提交于
      If a parameter isn't found we can suggest similar params:
      
      ```
      class BooksController < ActionController::Base
        def create
          params.require(:book).require(:name)
          head :ok
        end
      end
      
      post :create, params: { magazine: { name: "Mjallo!" } }
      
      param is missing or the value is empty: book
      Did you mean?  controller
                     action
                     magazine
      
      post :create, params: { book: { title: "Mjallo!" } }
      
      param is missing or the value is empty: name
      Did you mean?  title
      
      ```
      5411565d
    • V
      Update `fixture_file_upload` documentation to reflect recent changes. (#39340) · 1ab0e6b6
      Vitalii Khustochka 提交于
      * Update `fixture_file_upload` documentation to reflect recent changes. [ci skip]
      
      * Friendlier deprecation message for `fixture_file_upload`.
      
      Suggested change now can be copied and pasted into the code without modification.
      1ab0e6b6
  31. 18 5月, 2020 1 次提交
    • P
      Use DidYouMean for ActionNotFound · 3551a95e
      Petrik 提交于
      If an action isn't found on a controller we can suggest similar actions:
      
      ```
      The action 'indx' could not be found for SimpleController
      Did you mean?  index
      ```
      3551a95e
  32. 17 5月, 2020 1 次提交