Commit Graph

13004 Commits

Author SHA1 Message Date
Maxime Lapointe
f47ef36c4d
Log trace of causes for unhandled exceptions 2024-06-12 22:51:15 +00:00
Gannon McGibbon
6622075802
Merge pull request #52012 from Shopify/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called.
2024-06-06 11:23:47 -05:00
Zack Deveau
35858f1d9d
include the HTTP Permissions-Policy on non-HTML Content-Types
[CVE-2024-28103]

The application configurable Permissions-Policy is only
served on responses with an HTML related Content-Type.

This change allows all Content-Types to serve the
configured Permissions-Policy as there are many non-HTML
Content-Types that would benefit from this header.
(examples include image/svg+xml and application/xml)
2024-06-04 10:07:37 -07:00
Gannon McGibbon
7ac333858c Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-06-04 11:12:12 -05:00
Rafael Mendonça França
3922460df7
Link should be separated by comma.
See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link.
2024-05-31 22:04:38 +00:00
Rafael Mendonça França
8dc7a7fb15
Merge pull request #51975 from artfuldodger/patch-1
Clarify and make double rendering documentation consistent [ci skip]
2024-05-31 17:42:39 -04:00
Rafael Mendonça França
fe57bd2462
Lower case the link header
Since 1fbcf54289
the early hints will be checked against Rack::Link that requires all
headers to be lower cased.

Fixes #51961.
2024-05-31 21:00:22 +00:00
Jon Evans
625ec8301a Clarify and make double rendering documentation consistent
An action can _contain_ multiple renders/redirects, but only one can be _performed_.

"Attempting to try to" is redundant.

Also removes the `and return` recommendation in order to be consistent with the documentation updates from https://github.com/rails/rails/pull/45927
2024-05-31 12:42:44 -06:00
Jean Boussier
bc56661a3d
Merge pull request #51933 from zzak/51910
Handle case where script_name is a blank string
2024-05-31 11:12:29 +02:00
Cyril Blaecke
931d2a890c
Update permissions policy list 2024-05-29 22:40:05 +02:00
zzak
234191c03b
Handle case where script_name is a blank string
TBD: where is it being set as ""

wip: add regression test
2024-05-29 21:24:07 +09:00
Joe Haig
10dc425e8e
Add CSP mapping for 'wasm-unsafe-eval'
The `'wasm-unsafe-eval'` keyword for the Content Security Policy allows the
loading and execution of WebAssembly modules without the need to allow unsafe
JavaScript execution via `'unsafe-eval'`. A mapping is added so that the symbol
`:wasm_unsafe_evel` can be used for this keyword in the policy configuration in
`config/initializers/content_security_policy.rb`.
2024-05-28 18:39:48 +00:00
Jamie McCarthy
dc34e293e0
ActionPack: fix BrowserBlocker versions
css-nesting is not fully supported until Chrome 120, Opera 106:
https://caniuse.com/css-nesting
https://developer.mozilla.org/en-US/docs/Web/CSS/Nesting_selector#browser_compatibility
2024-05-24 19:50:05 +00:00
Rafael Mendonça França
cff6b2cd8d
Merge pull request #51874 from stiig/fix-colspan-for-rails-routes
Fix colspan for representing search results in the rails routes
2024-05-24 15:47:05 -04:00
eileencodes
d189cbcb56
Revert "Merge pull request #51614 from gmcgibbon/defer_route_drawing"
This reverts commit e97db3b3957781c781a61fb01265feb2b57688bb, reversing
changes made to a27a1751cfd499f69499e943f12e3400b55a323e.

This is breaking application routes when running without eager load enabled.
2024-05-24 09:59:41 -04:00
Vasiliy Matyushin
48d7feaebd fix colspan for HtmlTableFormatter and dynamic search for routes 2024-05-24 11:49:36 +05:00
zzak
a0621e5946
Private methods do not need :nodoc: to be private API
Follow up to #51279

Co-authored-by: Gabriel Amaral <1706819+gabriel-amaral@users.noreply.github.com>
2024-05-24 06:56:19 +09:00
Andy Waite
a8fdfffe18
Look up route from requirements (#51850)
* Lookup route from requirements

* Add docs

* Strings instead of symbols

S

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

* Update actionpack/lib/action_dispatch/routing/route_set.rb

Co-authored-by: Rafael Mendonça França <rafael@franca.dev>

---------

Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-05-23 11:37:45 -07:00
Hartley McGuire
8cbf969e09
Temporarily fix multi-paragraph definition lists
The rdoc markdown parser does not currently parse multi-paragraph
definition lists correctly. Instead of putting both paragraphs inside
a single definition, only the first paragraph ends up in the definition
and the second paragraph is rendered after the definition list as a code
block.

Since 7.2 appears to be coming soon, this commit fixes the second
paragraph rendering as a code block by turning it into a second
definition. This doesn't strictly seem like the "correct" fix (compared
to fixing the rdoc markdown parser) but it gives us the visual result
that we want until rdoc is fixed.
2024-05-21 11:48:01 -04:00
Rafael Mendonça França
37fd0e7fe4
Development of Rails 8.0 starts now
🎉
2024-05-13 16:45:20 +00:00
zzak
833c1c9a4d
Enable Lint/Debugger
This will prevent issues like be0cb4e8f9, which would have resulted in:

```
guides/rails_guides/generator.rb:16:1: W: Lint/Debugger: Remove debugger entry point require "debug".
require "debug"
^^^^^^^^^^^^^^^
```

Disabled the cop in actionpack tests for screenshot_helper and page_dump_helper:

```
actionpack/test/controller/integration_test.rb:1369:9: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
        save_and_open_page
        ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1381:11: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
          save_and_open_page
          ^^^^^^^^^^^^^^^^^^
actionpack/test/controller/integration_test.rb:1391:39: W: Lint/Debugger: Remove debugger entry point save_and_open_page.
      assert_raise(InvalidResponse) { save_and_open_page }
                                      ^^^^^^^^^^^^^^^^^^
```

```
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:111:13: W: Lint/Debugger: Remove debugger entry point page.save_page(absolute_html_path).
            page.save_page(absolute_html_path)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb:115:13: W: Lint/Debugger: Remove debugger entry point page.save_screenshot(absolute_image
_path).
            page.save_screenshot(absolute_image_path)
```

The DebuggerRequires option was first available in rubocop v1.63.0, in rubocop/rubocop#12766.
2024-05-13 13:41:18 +09:00
Gannon McGibbon
e97db3b395
Merge pull request #51614 from gmcgibbon/defer_route_drawing
Defer route drawing to the first request, or when url_helpers called
2024-05-12 10:17:57 -04:00
Gert Goet
111b6ab1fb
Example requires delimiter 2024-05-10 12:40:35 +02:00
Gannon McGibbon
e54f869e43 Defer route drawing to the first request, or when url_helpers called.
Executes the first routes reload in middleware, or when the route set
url_helpers is called. Previously, this was executed unconditionally on
boot, which can slow down boot time unnecessarily for larger apps with
lots of routes.
2024-05-08 23:43:06 -04:00
Jean Boussier
06d3b358df Replace allocations count by GC time in request logs
Allocations count is often an interesting proxy for performance,
but not necessarily the most relevant thing to include in request
logs, given they aren't a per thread metric, so the reporting
is widely innacurate in multi-threaded environments.

Since Ruby 3.1 there is now `GC.total_time` which is a monotonically
increasing counter of time spent in GC. It still isn't really a per
thread metric, but is is more interesting because it uses the same
unit as the response time, allowing to better see when you have a GC
pause performance issue.
2024-05-08 23:02:35 +02:00
Earlopain
6233309298
Resolve deprecation warning in latest selenium-webdriver
```
2024-04-26 09:36:45 INFO Selenium [:logger_info] Details on how to use and modify Selenium logger:
  https://selenium.dev/documentation/webdriver/troubleshooting/logging

2024-04-26 09:36:45 WARN Selenium [DEPRECATION] DriverFinder.path(options, service_class) is deprecated. Use DriverFinder.new(options, service).driver_path instead.
```
2024-04-26 12:28:42 +02:00
Taylor Chaparro
5889b8659e
Fix Mime::Type.parse for HTTP Accept with parameters
Fixes MIME parsing raising errors on valid parameters #51594.

Mime type lookups were updated to handle custom registered types as part of #48397.

This fix the strips out custom media range parameters before falling back to the default type creation.
2024-04-22 07:09:28 -07:00
Ryuta Kamizono
7db95ced41 Update comments for helper method generation
Follow up to #50596.
2024-04-22 22:14:42 +09:00
Rafael Mendonça França
73452ef8ca
Merge pull request #51096 from joshuay03/fix-missing-template-error-page-with-nested-controller-paths
[Fix #51095] Missing template error page showing incorrect view path example for nested controller path
2024-04-19 16:22:55 -03:00
Joshua Young
79f2099fb1
[Fix #51095] Missing template error page showing incorrect view path example for nested controller path 2024-04-19 19:06:17 +00:00
Nemanja Čorlija
8ba3144519
Fix typo in page_dump_helper.rb 2024-04-19 16:54:36 +02:00
Joé Dupuis
7f9ce6f62b
Add save_and_open_page helper to IntegrationTest
`save_and_open_page` is a capybara helper that lets developers
inspect the status of the page at any given point in their
test. This is helpful when trying to keep a short feedback loop while
working on a test.

This change adds a similar helper with matching signature to
integration tests.
2024-04-18 20:44:40 +00:00
Rafael Mendonça França
d1236c4b8d
Merge pull request #51479 from nhorton/patch-5
Don't preload Selenium browser when remote
2024-04-18 14:32:51 -03:00
Jean Boussier
b272be8f6b
Merge pull request #51523 from etiennebarrie/route-to-implicit-controller
Restore `to:` option in routes with an implicit controller
2024-04-17 17:14:04 +02:00
Sebastian Serth
33ee5d659d
Fix typo in Feature Policy for idle-detection
As listed in MDN, the policy is spelled as `idle-detection`, and not as `idle_detection`. Hence, browsers were unable to process the policy correctly, effectively ignoring it.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Permissions-Policy/idle-detection
2024-04-13 18:34:30 +02:00
Étienne Barrié
1dc7620b9f Respond with 406 when a browser is blocked by allow_browser
RFC 9110 specifies:

	The server MUST send an Upgrade header field in a 426 response
	to indicate the required protocol(s)

https://httpwg.org/specs/rfc9110.html#status.426

Status 406 Not Acceptable is more appropriate because it indicates the
resource

	does not have a current representation that would be acceptable
	to the user agent, according to the proactive negotiation header
	fields received in the request

https://httpwg.org/specs/rfc9110.html#status.406

With the proactive negociation section mentionining:

	implicit characteristics, such as the client's network address
	or parts of the User-Agent field.

https://httpwg.org/specs/rfc9110.html#proactive.negotiation
2024-04-11 10:50:24 +02:00
Étienne Barrié
36ff424c3b Restore to: option with an implicit controller
The `:to` option for routes can once again be a String without a
controller if the controller is implicitly provided by a nesting
`controller` or `resources` call.
2024-04-10 16:47:20 +02:00
Noah Horton
ce910c72da
Don't preload Selenium browser when remote 2024-04-03 13:06:50 -06:00
Hartley McGuire
5df5ddc75e
Regenerate some broken markdown in Action Pack
This can be reproduced using a version of rdoc that includes this fix:
- c65266437c

The fix correctly adds a newline between definition list items, which
was not added previously.

This commit was generated with the following commands:

```
$ git checkout 3079e8b0f894e9a7e85a3bbf42383dc0a616af41 -- actionpack/lib/action_controller/metal/conditional_get.rb
$ ./tools/rdoc-to-md --only=actionpack -a
```
2024-03-25 19:39:17 -04:00
Rafael Mendonça França
8922180af5
Merge pull request #51270 from skipkayhil/hm-fix-bold-label-list
Fix md label-lists rendering incorrectly [ci-skip]
2024-03-07 16:19:49 -05:00
Gabriel Amaral
2cd7460152 Making code branches explicit
Co-authored-by: Rafael Mendonça França <rafael@franca.dev>
2024-03-07 20:20:25 +00:00
Gabriel Amaral
b8e4640d72 Handling relative paths with extra URI parts. 2024-03-07 19:44:32 +00:00
Hartley McGuire
6640b85b69
Fix md label-lists rendering incorrectly
When converting docs from RDoc to Markdown, some label-lists ended up
not rendering properly. This appears to be due to RDoc's Markdown
parser not recognizing label-list labels if the label has additional
markup around it (in this case, bold markers `**`).

Additionally, the markdown label-list was missing newlines between list
items which also caused the label-list to not render correctly.

This commit fixes both of these issues for cases where the RDoc
originally used <b> tags in a label-list label. Since label-list labels
will already be bolded, there is no reason to also use `**` on the
labels.
2024-03-06 18:11:14 -05:00
Earlopain
f080d8f5d0
Fix crash for invalid Content-Type in ShowExceptions middleware 2024-03-04 09:12:35 +01:00
Rafael Mendonça França
ada3d775bd
Use Kernel#Array to wrap the default value 2024-02-27 01:37:54 +00:00
Rafael Mendonça França
d216d1ede7
Do not always mark the default translation as html safe
If the `_html` suffis isn't provided we should not mark the default
translation as html safe and escape it.
2024-02-27 01:36:40 +00:00
Gannon McGibbon
61b0a68940 Handle bad URIs when filtering redirects
rails/rails#51131 introduced parameter filtering for redirects. We
didn't account for invalid URIs though, and it changes the behaviour of
redirect_to to raise URI errors when we try to filter a bad URI.
Instead, we should fallback to filtering bad URIs entirely to preserve behaviour.
2024-02-23 00:11:24 -06:00
John Hawthorn
0f870c4354 Respect raise_on_missing_ in controller
Previously raise_on_missing_translations was not being respected in a
controller. This commit brings back the correct behaviour.
2024-02-21 13:18:58 -08:00
ooooooo_q
857f2e4a6a
fix XSS vulnerability when using translation
[CVE-2024-26143]
2024-02-21 10:20:05 -08:00
Aaron Patterson
a3f3c3e5d6
Fix ReDoS in accept header scanning
Thanks svalkanov for the patch!

[CVE-2024-26142]
2024-02-21 10:17:42 -08:00