| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
|
|
|
| |
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).
Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).
That cop and enforced style will reduce the our code review cost.
|
|
|
|
|
|
|
|
|
| |
When a route was defined within an optional scope, if that route didn't
take parameters the scope was lost when using path helpers. This patch
ensures scope is kept both when the route takes parameters or when it
doesn't.
Fixes #33219
|
| |
|
| |
|
|\
| |
| | |
Honor shallow: false on nested resources
|
| |
| |
| |
| |
| |
| |
| |
| | |
Previously there was no way to place a non-shallow resource inside a parent
with `shallow: true` set. Now you can set `shallow: false` on a nested child
resource to generate normal (non-shallow) routes for it.
Fixes #23890.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| | |
* Fix typo in the value of ENCRYPTED_SIGNED_COOKIE_SALT constant
* Fix value of cookie in with authenticated encryption flag off in tests
[Emil Shakirov + Ryuta Kamizono]
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
After this change it's not possible anymore to configure routes
like this:
routes.draw do
resources :users, param: "name/:sneaky"
end
Fixes #30467.
|
| |
| |
| |
| | |
Now that secret_token was removed all this code is now dead.
|
| |
| |
| |
| |
| | |
Raises an ArgumentError when multiple root routes are defined in the
same context instead of assigning nil names to subsequent roots.
|
|\ \
| | |
| | | |
Fix optionally scoped root route unscoped access
|
| | | |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This PR fixes an issue when the following situation occurs.
If you define a class like this
class MyConstraint
def call(*args)
# for some reason this is defined
end
def matches?(*args)
# checking the args
end
end
and try to use it as a constraint
get "/", to: "home#show", constraints: MyConstraint.new
if its `matches?` method returns `false` there will be an error for the
mapper will ask for the constraint arity, thinking it is a proc, lambda
or method.
This PR checks for the presence of the `arity` method on the constraint
calling it only if present, preventing the error while keeping the basic
behavior.
|
| |
| |
| |
| | |
Follow up of #32605.
|
| |
| |
| |
| |
| | |
This autocorrects the violations after adding a custom cop in
3305c78dcd.
|
| | |
|
| | |
|
| |
| |
| |
| | |
Follow up of #31432.
|
| |
| |
| |
| | |
Fixes #31220.
|
| |
| |
| |
| |
| |
| | |
Using the action_dispatch.cookies_rotations interface, key rotation is
now possible with cookies. Thus the secret_key_base as well as salts,
ciphers, and digests, can be rotated without expiring sessions.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since this test changed in 9220935 I noticed that it really doesn't make
sense anymore. I split the tests into 2 groups to explain what each one
does.
First these routes should throw a `bad_request` when the encoding isn't
valid. We're expecting UTF8 encoding and passing binary, that should be
a bad request.
For the second test we are setting the `show` route to set
`self.binary_params_for?` for that route which will convert the
parameters and return a `:ok` instead of a `:bad_request`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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*
|
| | |
|
| |
| |
| |
| |
| | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently, raise `BadRequest` if params encoding is invalid.
https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/http/parameters.rb#L64..L74
https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/request/utils.rb#L26..L39
However, env values are ensure encoded in ASCII 8 BIT at rack 2.0.3.
https://github.com/rack/rack/commit/68db9aa99e3e2775a58621f658b2a7a0f67db459
Therefore, even if specify an invalid urls, it will not cause an error.
|
| |
| |
| |
| |
| | |
Since this protection is now in Parameters we can use it instead of
reimplementing again.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The current check for whether to add an optional format to the path
is very lax and will match things like `:format_id` where there are
nested resources, e.g:
resources :formats do
resources :items
end
Fix this by using a more restrictive regex pattern that looks for
the patterns `(.:format)`, `.:format` or `/` at the end of the path.
Note that we need to allow for multiple closing parenthesis since
the route may be of this form:
get "/books(/:action(.:format))", controller: "books"
This probably isn't what's intended since it means that the default
index action route doesn't support a format but we have a test for
it so we need to allow it.
Fixes #28517.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In 9b654d4 some params munging was added to ensure that they were
set whenever `recognize_path` would call either a proc or callable
constraint. Since we no longer mutate the environment hash within
the method it's now unnecessary and actually causes params to leak
between route matches before checking constraints.
Fixes #28398.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In ca324a0 the flash middleware was effectively removed by its
constructor returning the app it was passed and the `commit_flash`
call was moved to the `ActionController::Metal#dispatch` method.
This broke any redirect routes that modified the flash because the
redirect happens before `dispatch` gets called.
To fix it, this commit adds a `commit_flash` call in the `serve`
method of `ActionDispatch::Routing::Redirect`.
Fixes #27992.
|
| |
| |
| |
| | |
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
|
| | |
|
| | |
|
| |
| |
| |
| | |
`ActionDispatch::Routing::Mapper#match`
|
| |
| |
| |
| | |
`ActionDispatch::Routing::Mapper#match`
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Currently a misleading "missing required keys" error is thrown when a param
fails to match the constraints of a particular route. This commit ensures that
these params are recognised as unmatching rather than missing.
Note: this means that a different error message will be provided between
optimized and non-optimized path helpers, due to the fact that the former does
not check constraints when matching routes.
Fixes #26470.
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
This removes the following warning.
```
./test/dispatch/routing_test.rb:3696: warning: method redefined; discarding old test_namespaced_roots
./test/dispatch/routing_test.rb:1632: warning: previous definition of test_namespaced_roots was here
```
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The PR #20940 enabled the use of multiple roots with different constraints
at the top level but unfortunately didn't work when those roots were inside
a namespace and also broke the use of root inside a namespace after a top
level root was defined because the check for the existence of the named route
used the global :root name and not the namespaced name.
This is fixed by using the name_for_action method to expand the :root name to
the full namespaced name. We can pass nil for the second argument as we're not
dealing with resource definitions so don't need to handle the cases for edit
and new routes.
Fixes #26148.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Since e852daa6976cc6b6b28ad0c80a188c06e226df3c only the verb methods
where extracting the defaults options. It was merged a fix for the
`root` method in 31fbbb7faccba25b2e3b5e10b8fca1468579d629 but `match`
was still broken since `:defaults` where not extracted.
This was causing routes defined using `match` and having the `:defaults`
keys to not be recognized.
To fix this it was extracted a new private method with the actual
content of `match` and the `:defaults` extracting was moved to `match`.
|
| |
| |
| |
| |
| |
| |
| |
| | |
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces
Fix all violations in the repository.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| | |
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
|
|\ \
| | |
| | |
| | | |
Fix keyed defaults with root
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| | |
The merging of the 'defaults' option was moved up the stack in e852daa
This allows us to see where these options originate from the standard
HttpHelpers (get, post, patch, put, delete)
Unfortunately this move didn't incorporate the 'root' method, which has
always allowed the same 'defaults' option before.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|