| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently `:api:` tag has leaked on the doc directly since RDoc doesn't
support `:api:` tag directive.
http://api.rubyonrails.org/v5.1/classes/AbstractController/Rendering.html
So `:api: private` doesn't work as expected. We are using `:nodoc:` for
the purpose.
Related #13989.
|
|\ \
| | |
| | |
| | |
| | | |
koic/fix_cant_modify_frozen_string_error_in_ac_rendering
Fix `can't modify frozen String` error in AC::Rendering
|
| | | |
|
| | |
| | |
| | |
| | | |
This is no longer used since 79a5ea9eadb4d43b62afacedc0706cbe88c54496.
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
Don't use remove_method or remove_possible_method just before a new
definition: at best the purpose is unclear, and at worst it creates a
race condition.
Instead, prefer redefine_method when practical, and
silence_redefinition_of_method otherwise.
|
| | |
|
| | |
|
| |
| |
| |
| | |
Fixes regression ActionController::UnpermittedParameters not raised. The inner hook was being executed twice, once when ActionController::Base was loaded and again when ActionController::API was loaded. As options.delete operations inside the block are not idempotent, the second time it was run there was no configuration option available
|
|\ \
| | |
| | | |
Eager load controller actions to reduce response time of the first request
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
On the first request, ActionController::Base#action_methods computes
and memoized the list of available actions [1]. With this PR we move
this expensive operation into eager load step to reduce response time
of the first request served in production.
This also reduces the memory footprint when running on forking server
like Unicorn.
[1] https://github.com/rails/rails/blob/a3813dce9a0c950a4af7909111fa730a2622b1db/actionpack/lib/abstract_controller/base.rb#L66-L77
|
|/ / |
|
|\ \
| | |
| | | |
Make actionpack frozen string friendly
|
| | | |
|
| | | |
|
|/ / |
|
| | |
|
| |
| |
| |
| |
| |
| | |
Since we now default to `protect_from_forgery with: :exception`,
provide a wrapper to `skip_before_action :verify_authenticity_token`
for disabling forgery protection.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Rather than protecting from forgery in the generated
ApplicationController, add it to ActionController::Base by config. This
configuration defaults to false to support older versions which have
removed it from their ApplicationController, but is set to true for
Rails 5.2.
|
| | |
|
| |
| |
| |
| |
| |
| |
| | |
We need to configure it only when ActionController::Base is loaded
otherwise configs on initializers will not work.
Closes #29527.
|
|\ \ |
|
| |\ \
| | | |
| | | | |
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
|
| | |/ / |
|
| |\ \ \
| | | | |
| | | | |
| | | | | |
Make ActiveSupport frozen-string-literal friendly.
|
| | | |/
| | |/|
| | | |
| | | | |
Plus a couple of related ActionPack patches.
|
|/ / / |
|
| | | |
|
| |/
|/|
| | |
Fixes https://github.com/rails/rails/issues/29617
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| | |
Ref: https://github.com/rails/rails/blob/33b596709388cc48d90ab6d1de99d7bd6e85f916/actionpack/lib/action_controller/metal/strong_parameters.rb#L52..L56
|
|/
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without `permit`, `AC::Parameters#to_query` raise
`AC::UnfilteredParameters`.
```ruby
params = ActionController::Parameters.new({
name: "David",
nationality: "Danish"
})
params.to_query
# => ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash
```
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Allow a default value to be declared for class_attribute
* Convert to using class_attribute default rather than explicit setter
* Removed instance_accessor option by mistake
* False is a valid default value
* Documentation
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
We are talking about a list of parameters even so we need to use plural.
Even if we were talking about the instance of the Parameters object we
would have to use the capital and monospaced font.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|/
|
|
|
|
| |
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.
|
|
|
|
| |
[ci skip]
|