Commit Graph

15021 Commits

Author SHA1 Message Date
John Bampton 2bb445d25f chore: fix spelling in `controller/filters_test.rb` 2021-04-13 23:34:59 +10:00
Rafael França 127dd06df6
Merge pull request #41935 from SkipKayhil/deprecate-rack-runtime
Remove Rack::Runtime and deprecate referencing it
2021-04-12 15:12:20 -04:00
Rafael Mendonça França 4354e3ae49
Don't define methods using the method modifier in the same line as the method
Our style guide use block method modifiers, not inline method modifiers.
2021-04-12 18:49:54 +00:00
Hartley McGuire 7bfcf4b313 Remove Rack::Runtime and deprecate referencing it
Previous discussion: #38412, #38325, 37423e4, 24f9c03

- Rack::Runtime is replaced by FakeRuntime, which is a dummy middleware
  that just passes requests on and cannot be used in middleware operations
- Using Rack::Runtime in middleware operations (relative inserts, moves,
  etc.) throws a deprecation warning and uses FakeRuntime instead
- if an application adds Rack::Runtime explicitly (use, unshift, etc.),
  then the deprecation warning does not happen and FakeRuntime is
  ignored
- docs are updated to no longer reference Rack::Runtime
2021-04-12 14:31:12 -04:00
Ryuta Kamizono ddab2254df
Merge pull request #41919 from jbampton/fix-html-script-tag
chore: remove redundant MIME type from HTML script tag
2021-04-12 07:30:51 +09:00
John Bampton 44c32c1605 chore: remove redundant MIME type from HTML script tag
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script
2021-04-12 06:57:03 +10:00
John Bampton c757ab2efe chore: remove unneeded trailing whitespace 2021-04-12 01:44:46 +10:00
John Bampton 8f2c74046f chore: fix spelling in actionpack/CHANGELOG.md 2021-04-12 00:18:49 +10:00
Jean Boussier 3f59640016 Stop checking if ruby2_keywords is defined 2021-04-11 13:42:02 +02:00
Andrew White 64107f367a
Merge pull request #41874 from jacobherrington/error-page-css-and-a11y-improvements
Error page CSS and a11y improvements
2021-04-10 12:34:30 +01:00
Ryuta Kamizono 12c4b77c55 `SecureRandom.urlsafe_base64` doesn't have `padding: false` keyword argument
Actually it is regarded truthy as `padding = { padding: false }`.

https://docs.ruby-lang.org/en/2.7.0/Random/Formatter.html#method-i-urlsafe_base64
2021-04-08 18:08:55 +09:00
Jacob Herrington 126cd61ed4
Address basic accessibility issues
These are super basic issues that were flagged by the axe browser
extension.

I tried to change as few things as possible to avoid breaking anything
that might be making assumptions about the markup on this page.

Generally, there is a lot more work that would need to be done on these
pages to make them as friendly as possible to assistive technologies.

Relevant:
- https://dequeuniversity.com/rules/axe/4.1/landmark-one-main
- https://dequeuniversity.com/rules/axe/4.1/color-contrast
2021-04-07 23:16:58 -05:00
Jacob Herrington 46c19a2c9c
Add hover animation for diagnostics summary 2021-04-07 22:17:58 -05:00
Jacob Herrington 8e78ff12dc
Fix toggle function
The toggle function relied on inline styles, but that method of toggle
an element is not necessary.

Relevant: classList is has ~99% browser support
- https://caniuse.com/?search=classlist
2021-04-07 21:49:02 -05:00
Jacob Herrington d70473b53a
Remove unnecessary inline styles 2021-04-07 21:48:28 -05:00
Jacob Herrington 9861790b6b
Condense duplicate selectors 2021-04-07 21:10:12 -05:00
Alex Smith 0680658624 Allow 'private, no-store' Cache-Control header
https://github.com/rails/rails/pull/39461 changed the `no-store`
directive for the `Cache-Control` header to be exclusive, i.e. when
setting `Cache-Control` to `private, no-store`, this is simplified to
just `no-store`. `private` should typically be superfluous there, but
it's not always.

For instance, Fastly "does not currently respect no-store or no-cache
directives" and says that "if you need to prevent caching by both Fastly
and web browsers, we recommend combining the private directive with
max-age=0 or no-store".

https://docs.fastly.com/en/guides/configuring-caching#do-not-cache

Since it's not possible to override this directive reduction behaviour,
the changes in #39461 prevent Fastly users from upgrading Rails.

This changes the behaviour to allow setting a 'private, no-store' header
when private is specified - similar to how 'public' can be specified
when 'no-cache' is, but not as a default.

Fixes https://github.com/rails/rails/issues/40798
2021-04-05 14:20:17 +10:00
Brian Buchalter 6be9c498bc Provide context when logging unpermitted parameters
Currently, the payload of the unpermitted_parameters.action_controller
events emitted by StrongParameters does not provide enough information for
developers to understand which controller and action received the
unpermitted parameters. This PR modifies ActionController::Parameters to
allow callers to specify a "context" which is included in the logging
payload.

*Implementation Strategy*
Since the ActionController::Parameters class is only loosely coupled
with controllers and can technically be used in any context, this PR
expects the caller to provide logging context.

Since StrongParameters is caller in Rails and has access to the
request object I chose to provide a payload similar to the
start_processing.action_controller event.
2021-03-31 17:15:23 -06:00
Christian Sutter eab5a3877e Fix deprecation warning on Actionpack request test
The way this test initializes `ActionDispatch::RemoteIp` has been
deprecated in #40789. This makes the test append to the existing
trusted proxy list instead of assigning a single value.
2021-03-26 17:28:38 +00:00
Rafael Mendonça França 30c9bff7e7
Fix indentation 2021-03-24 23:06:19 +00:00
Rafael Mendonça França 7d2d00a334
Fix handling of ParseError in controllers
It regressed in #34894, which moved the rescue to the wrong method.
`_wrapper_enabled?` can access the parameters and the exception will
raise there before even entering `_perfomr_parameter_wrapping`.

Closes #38285.
2021-03-24 22:53:27 +00:00
Rafael França 7702ce8243
Merge pull request #40789 from csutter/deprecate-remote-ip-single-value
Deprecate assigning single `trusted_proxies` value
2021-03-24 02:27:57 -04:00
Ryuta Kamizono 043184d903 Fix end alignment 2021-03-21 15:46:36 +09:00
Jean Boussier 8a3fcad2d2 Use ... argument forwarding instead of ruby2_keywords when possible 2021-03-19 16:53:06 +01:00
Jens Dahl Møllerhøj 7d10ce1c92
fix typo 2021-03-16 23:57:22 +01:00
Xavier Noria 43a7f68ae3 Deletes AS::Dependencies::Blamable
This is an internal class which is no longer needed.
2021-03-08 17:10:42 +01:00
Kasper Timm Hansen 7bc962fe99
Merge pull request #41635 from sunny/add-pointer-cursor-to-rescue-layout
Add pointer cursor to Exception layout
2021-03-07 20:57:07 +01:00
Tsukuru Tanimichi 7c5c8f9e48
[ci skip] Not `masked_authenticity_token` but `form_authenticity_token` should be a public API
`form_authenticity_token` would be a public API because:

1. The usage of this method [is described in the guide](291a3d2ef2/guides/source/action_controller_overview.md (request-forgery-protection)) and already [many Rails users depend on this method](https://stackoverflow.com/questions/941594/understanding-the-rails-authenticity-token).
2. This method [is set as helper_method](291a3d2ef2/actionpack/lib/action_controller/metal/request_forgery_protection.rb (L97)) and called form ActionView. Inside the Rails components, it's already used as a public interface of ActionController.
2021-03-07 22:57:08 +09:00
Sunny Ripert 433f9707a1 Add pointer cursor to Exception layout 2021-03-07 14:57:03 +01:00
Christian Schmidt 6cd184ff0f
Use image/jpeg instead of non-standard image/jpg 2021-03-05 13:14:11 -05:00
Aaron Patterson d5ac941ddc
Remove special case filtering for Procs.
I'm writing this patch for two purposes:

1. I want to reduce the number of times `object_id` is called.  Calling
   `object_id` can have negative impacts on performance in Ruby 2.7+, so
   it would be nice to stop calling it.

2. I'm not sure why we're treating lambdas specially here.  It looks
   like we wanted to prevent people from skipping callbacks that were
   defined with a lambda, but I think that is silly.  If the user has a
   reference to a lambda, and they want to skip it, we should let them.

I think this cleans up some code, helps with performance, and is a more
intuitive interface.
2021-03-02 17:20:35 -08:00
Gannon McGibbon 1e04c04ecb
Merge pull request #41525 from gmcgibbon/redirection_satety_note
[ci skip] Note dangerous use of redirect_to
2021-02-23 15:55:20 -05:00
Gannon McGibbon 991b17a032 [ci skip] Note dangerous use of redirect_to 2021-02-23 15:37:46 -05:00
ojab e332b0e941
Allow passing anything with `#to_str` into `redirect_to` 2021-02-22 23:30:28 +00:00
David Heinemeier Hansson b90875ebd9
Add ActionController::Live::Buffer#writeln the write a line to the stream with a newline included (#41501)
* Add ActionController::Live::Buffer#writeln to write a line to the stream with a newline included

* Don't add newlines to strings that already have them
2021-02-20 10:02:49 +01:00
David Heinemeier Hansson 90049a4107
Add send_stream to do for dynamic streams what send_data does for static files (#41488) 2021-02-18 22:35:36 +01:00
Rafael França 983a50da87
Merge pull request #41467 from fredplante/improve-rack-test-integration
Improve rack_test integration for system tests
2021-02-17 10:04:40 -05:00
Frédéric Planté adab999e09 Add rack_test driver to System Tests 2021-02-17 00:50:28 +01:00
John Hawthorn d6ca73306c Force _routes to be redefined on re-inclusion
This fixes an regression where _routes were set incorrectly when the
inheritance chain went from one route namespace (isolated engine or main
app) to another and then back to the original. Because the url_helpers
module was being cached and was being re-included this was not setting
_routes.

This commit solves the issue by detecting that case and redefining
_routes in that case. We could have always performed the redefinition,
but it's a pretty uncommon case, so we might as well only do it when
necessary.
2021-02-16 11:55:22 -08:00
Jonathan Hefner 4f1f63b98a
Merge pull request #41441 from jonathanhefner/apidocs-inline-code-markup
Fix inline code markup [ci-skip]
2021-02-15 11:16:44 -06:00
Jonathan Hefner 167f5c8065 Fix inline code markup [ci-skip]
RDoc Markup does not support backticks the way Markdown does to mark up
inline code.  Additionally, `<tt>` must be used to mark up inline code
that includes spaces or certain punctuation characters (e.g. quotes).
2021-02-14 11:20:35 -06:00
Kasper Timm Hansen 7f02924fe6
Merge pull request #41435 from jonathanhefner/refactor-cve-2021-22881-fix
Refactor CVE-2021-22881 fix
2021-02-14 16:50:43 +01:00
Jonathan Hefner a21ebfa1c9 Refactor CVE-2021-22881 fix
Follow-up to 83a6ac3fee.

This allows `HTTP_HOST` to be omitted as before, and reduces the number
of object allocations per request.

Benchmark:

```ruby
 # frozen_string_literal: true
require "benchmark/memory"

HOST = "example.com:80"
BEFORE_REGEXP = /\A(?<host>[a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])(:\d+)?\z/
AFTER_REGEXP = /(?:\A|,[ ]?)([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9.:]+\])(?::\d+)?\z/i

Benchmark.memory do |x|
  x.report("BEFORE (non-nil X-Forwarded-Host)") do
    origin_host = BEFORE_REGEXP.match(HOST.to_s.downcase)[:host]
    forwarded_host = BEFORE_REGEXP.match(HOST.to_s.split(/,\s?/).last)[:host]
  end

  x.report("BEFORE (nil X-Forwarded-Host)") do
    origin_host = BEFORE_REGEXP.match(HOST.to_s.downcase)[:host]
    forwarded_host = BEFORE_REGEXP.match(nil.to_s.split(/,\s?/).last)
  end

  x.report("AFTER (non-nil X-Forwarded-Host)") do
    origin_host = HOST&.slice(AFTER_REGEXP, 1) || ""
    forwarded_host = HOST&.slice(AFTER_REGEXP, 1) || ""
  end

  x.report("AFTER (nil X-Forwarded-Host)") do
    origin_host = HOST&.slice(AFTER_REGEXP, 1) || ""
    forwarded_host = nil&.slice(AFTER_REGEXP, 1) || ""
  end
end
```

Results:

```
BEFORE (non-nil X-Forwarded-Host)
                       616.000  memsize (   208.000  retained)
                         9.000  objects (     2.000  retained)
                         2.000  strings (     1.000  retained)
BEFORE (nil X-Forwarded-Host)
                       328.000  memsize (     0.000  retained)
                         5.000  objects (     0.000  retained)
                         2.000  strings (     0.000  retained)
AFTER (non-nil X-Forwarded-Host)
                       248.000  memsize (   168.000  retained)
                         3.000  objects (     1.000  retained)
                         1.000  strings (     0.000  retained)
AFTER (nil X-Forwarded-Host)
                        40.000  memsize (     0.000  retained)
                         1.000  objects (     0.000  retained)
                         1.000  strings (     0.000  retained)
```
2021-02-13 12:03:23 -06:00
Ayrton De Craene 2526938b32 Calculate the minimum/maximum from an enumerable's extracted elements
```
payments = [Payment.new(5), Payment.new(15), Payment.new(10)]
payments.minimum(:price) # => 5
payments.maximum(:price) # => 20
```
2021-02-12 17:37:53 +01:00
Rafael Mendonça França a6a121163c
Remove unnessary escape char in Regexp
Fix the test by defining a valid host on the mocked requests.
2021-02-10 22:59:17 +00:00
Aaron Patterson 83a6ac3fee
Prevent open redirect when allowed host starts with a dot
[CVE-2021-22881]

Thanks to @tktech (https://hackerone.com/tktech) for reporting this
issue and the patch!
2021-02-10 20:47:49 +00:00
Ryuta Kamizono 7b680baea2 Remove `require "active_support/core_ext/symbol/starts_ends_with"`
Ruby 2.7 has native `Symbol#start_with?` and `Symbol#end_with?`.
2021-02-09 22:31:09 +09:00
Rafael França 3f435fb9fa
Merge pull request #41363 from ricardotk002/use-enumerator-all-with-classes
Use Enumerator#all? and Enumerator#any? with classes instead of iterations
2021-02-08 14:35:20 -05:00
Ryuta Kamizono a33334ada1
Merge pull request #41359 from andrehjr/remove-2-6-ruby-code
Removing Ruby 2.6 monkeypatch from active_support/core_ext/uri
2021-02-08 03:46:07 +09:00
André Luis Leal Cardoso Junior 52363d9586 Removing monkeypatched `URI#unescape` since main branch follows ruby 2.7 2021-02-07 08:20:17 -03:00