| Commit message (Collapse) | Author | Age | Files | Lines |
|\
| |
| | |
Don't wrap parameters if query parameter exists
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We want to avoid overwriting a query parameter with the wrapped
parameters hash. Previously this was implemented by merging the wrapped
parameters at the root level if the key already existed, which was
effectively a no-op. The query parameter was still overwritten in the
filtered parameters hash, however.
We can fix that discrepancy with a simpler implementation and less
unnecessary work by skipping parameter wrapping entirely if the key was
sent as a query parameter.
|
| |
| |
| |
| |
| | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
|\ \
| | |
| | |
| | | |
Enforce frozen string in Rubocop
|
| | | |
|
|/ /
| |
| | |
Fixes https://github.com/rails/rails/issues/29617
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
- When making a request to a controller that redirects, `follow_redirect!` would not reset the `html_document` ivar, it only resets the `html_document` ivar from the session (not the runner)
- If one was doing something like this;
```ruby
get '/redirect'
assert_select 'you are being redirected'
follow_redirect!
# html_document is memoized and doesn't get reset
```
- To fix the issue we can do the same for any other methods (`get`, `post`...) and define a method in the runner that delegates to the session but clears the html_document_first
- Fixes #29367
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We shouldn't perform parameter wrapping if it would overwrite one of the
parameters sent with the request, as that would interfere with reading
the parameter directly from the top level `params` hash.
The current implementation has logic for this case, but it doesn't
handle `nil`/`false` values, which means these parameters:
{ "user" => nil }
are transformed into this `params` hash:
{ "user" => { "user" => nil } }
and `params["user"]` no longer returns the original parameter value.
|
| |
|
|
|
|
|
|
| |
".. with __dir__ we can restore order in the Universe." - by @fxn
Related to 5b8738c2df003a96f0e490c43559747618d10f5f
|
| |
|
|
|
|
|
|
|
|
| |
In order to fully support the same interface as `Hash#delete`, we need
to pass the block through to the underlying method, not just the key.
This used to work correctly, but it regressed when
`ActionController::Parameters` stopped inheriting from `Hash` in 5.0.
|
| |
|
|
|
|
|
| |
Since this protection is now in Parameters we can use it instead of
reimplementing again.
|
|
|
|
|
|
|
|
|
|
| |
Previously it was raising an error because it may be unsafe to use those
methods in a unpermitted parameter. Now we delegate to to_h that already
raise an error when the Parameters instance is not permitted.
This also fix a bug when using `#to_query` in a hash that contains a
`ActionController::Parameters` instance and was returning the name of the
class in the string.
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
Now methods that implicit convert objects to a hash will be able to work
without requiring the users to change their implementation.
This method will return a Hash instead of a HashWithIndefirentAccess
to mimic the same implementation of HashWithIndefirentAccess#to_hash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Before we returned either an empty hash or only the always permitted
parameters (:controller and :action by default).
The previous behavior was dangerous because in order to get the
attributes users usually fallback to use to_unsafe_h that could
potentially introduce security issues.
The to_unsafe_h API is also not good since Parameters is a object that
quacks like a Hash but not in all cases since to_h would return an empty
hash and users were forced to check if to_unsafe_h is defined or if the
instance is a ActionController::Parameters in order to work with it.
This end up coupling a lot of libraries and parts of the application
with something that is from the controller layer.
|
| |
|
|
|
|
|
|
|
| |
Effectively treat nil values as "auto", e.g. whatever a form helper
chooses to interpret it as.
But treat an explicitly assigned false value as disabling.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I came up against this while dealing with a misconfigured server. The
browser was setting the Origin header to "https://example.com", but the
Rails app returned "http://example.com" from request.base_url (because
it was failing to detect that HTTPS was used).
This caused verify_authenticity_token to fail, but the message in the
log was "Can't verify CSRF token", which is confusing because the
failure had nothing to do with the CSRF token sent in the request. This
made it very hard to identify the issue, so hopefully this will make it
more obvious for the next person.
|
|\
| |
| | |
Do not include default response headers for AC::Metal
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In Rails 4.2, `ActionController::Metal` controllers did not include the
default headers from `ActionDispatch::Response`. However, through e16afe6, and a
general shift towards having `ActionController::Metal` objects contain
`ActionDispatch::Response` objects (instead of just returning an array
of status, headers, and body), this behavior was lost. This PR helps to
restore the original behavior by having `ActionController::Metal`
controllers generate Response objects without the default headers, while
`ActionController::Base` now overrides the factory method to make sure
its version does have the default headers.
|
|\ \
| |/
|/| |
Add an alias for reverse_merge to with_defaults
|
| |
| |
| |
| |
| |
| | |
In the context of controller parameters, reverse_merge is commonly used
to provide defaults for user input. Having an alias to reverse_merge
called with_defaults feels more idiomatic for Rails.
|
|/ |
|
|\
| |
| | |
Fix store accessors in parameters test
|
| |
| |
| |
| |
| |
| |
| |
| | |
* The method name must be `stored_attributes`, not `stores_attributes`.
* `attribute_names` must return a non-empty value. Because
`stored_attributes` is not checked if `attribute_names` is empty.
Follow up to #28056
|
|/
|
|
| |
Closes #28554
|
|\
| |
| | |
Wrap stored accessors in parameters
|
| |
| |
| |
| | |
Modified params wrapper to account for model's stored_attributes
|
| | |
|
|/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This reverts commit c6f9f8c28a720ad4ec7cf3613dddfa451d5968e2, reversing
changes made to c309073c7476f50dfb1e796d058580f176101c36.
Reason: This is fixing the behavior in the wrong place. Now the request
path after the request is nil and there is no way to assert that.
Also the test that was added in that PR also fails in 4.2 where the
reporter says it was passing. The reason the bahavior changed between
Rails 4.2 and Rails 5 is that the format in the path is now respected.
The correct way to fix the problem is not doign two requests in the same
controller test and use integrations tests. This change caused a
regression between Rails 5.0.1 and 5.0.2.
|
|
|
|
| |
`env` is undefined.
|
| |
|
|
|
|
|
| |
- This PR adds the `reverse_merge` and `reverse_merge!` method to `ActionController::Parameters`
- Fixes #28353
|
| |
|
| |
|
|
|
|
| |
Further missing requires for Timeout exposed due to Bundler 1.14.5
|
|
|
|
| |
Closes #28033
|
| |
|
|
|
|
| |
empty lines
|
|
|
|
|
|
|
| |
```
go get -u github.com/client9/misspell/cmd/misspell
misspell -w -error -source=text .
```
|
|
|
|
|
|
|
|
|
|
| |
Prevents PATH_INFO from being used to infer the request format in later
test requests when no explicit format is given.
As the request PATH_INFO may be set before a request, it can't be
deleted during pre-request scrubbing.
Fixes #27774
|
|
|
|
|
|
| |
These are followups for 307065f959f2b34bdad16487bae906eb3bfeaf28,
but TBH I'm personally not very much confortable with this style.
Maybe we could override assert_equal in our test_helper not to warn?
|
| |
|
|\
| |
| | |
make `render` work with AC::Params
|
| |
| |
| |
| |
| |
| |
| |
| | |
In 4.2, since AC::Params inherited `Hash`, processing in the case of
`Hash` was done. But in 5.x, since AC::Params does not inherit `Hash`,
need to add care for AC::Params.
Related to 00285e7cf75c96553719072a27c27e4ab7d25b40
|