aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
Commit message (Collapse)AuthorAgeFilesLines
* Routes from Engine Railties should not be an infinite loopAaron Patterson2018-09-261-2/+4
|
* Allow helpers to be deferred until the routes have been finalizedAaron Patterson2018-09-251-0/+22
| | | | | | | | | | | | | | | | ActiveStorage::BaseController subclasses ActionController::Base. ActionController::Base has an "inherited" hook set that includes the routing helpers to any subclass of AC::Base. Since ActiveStorage::BaseController is a subclass of AC::Base, it will get routing helpers included automatically. Unfortunately, when the framework is eagerly loaded, ActiveStorage::BaseController is loaded *before* the applications routes are loaded which means it attempts to include an "in flight" module so it gets an exception. This commit allows a class that's interested in being extended with routing helpers register itself such that when the routes are finalized, it will get the helpers included. If the routes are already finalized, then the helpers get included immediately.
* Eagerly build the routing helper module after routes are committedAaron Patterson2018-09-253-14/+44
| | | | | | | | | | | | | | This commit eagerly builds the route helper module after the routes have been drawn and finalized. This allows us to cache the helper module but not have to worry about people accessing the module while route definition is "in-flight", and automatically deals with cache invalidation as the module is regenerated anytime someone redraws the routes. The restriction this commit introduces is that the url helper module can only be accessed *after* the routes are done being drawn. Refs #24554 and #32892
* Merge pull request #33973 from rails/remove-catch-allAaron Patterson2018-09-251-0/+5
|\ | | | | Remove deprecated catch-all route in the AV tests
| * Add hack to deal with warningsAaron Patterson2018-09-241-1/+1
| | | | | | | | | | We should be able to remove this once the catch-all route is gone from AP
| * Remove deprecated catch-all route in the AV testsAaron Patterson2018-09-241-0/+5
| | | | | | | | | | | | | | | | This commit removes a deprecated catch-all route in the AV tests. It defines and includes the necessary routes for each test such that we don't need the catch-all anymore. This also helps push us toward #33970
* | Merge pull request #33829 from mtsmfm/encode-filenameKasper Timm Hansen2018-09-231-0/+45
|\ \ | | | | | | Encode Content-Disposition filenames on send_data and send_file
| * | Encode Content-Disposition filenames on send_data and send_fileFumiaki MATSUSHIMA2018-09-131-0/+45
| | |
* | | Enable `Performance/UnfreezeString` copyuuji.yaginuma2018-09-2311-19/+18
| |/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
* | Merge pull request #32932 from y-yagi/fixes_32920Yuji Yaginuma2018-09-201-1/+1
|\ \ | | | | | | Add CSP nonce to `style-src` directive
| * | Add CSP nonce to `style-src` directiveyuuji.yaginuma2018-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For nonce, only `script-src` and` style-src` are meaningful in the definition of Content Security Policy Level 2. https://www.w3.org/TR/CSP2/#script-src-nonce-usage https://www.w3.org/TR/CSP2/#style-src-nonce-usage Therefore, I think that customization function not needs and it is enough to enable both directives inside the framework. Fixes #32920
* | | [ci skip] Fix documentation for Response#content_typeprintercu2018-09-141-10/+10
| |/ |/|
* | Merge pull request #33718 from kddeisz/permit-listMatthew Draper2018-08-292-6/+3
|\ \ | | | | | | Finish converting whitelist and blacklist references
| * | Permit list usage cleanup and clearer documentationKevin Deisz2018-08-271-4/+1
| | |
| * | Convert remaining usage of whitelist and blacklistKevin Deisz2018-08-241-2/+2
| | |
| * | Convert over the rest of the whitelist referencesKevin Deisz2018-08-241-1/+1
| | |
* | | Focus search input after page load on /rails/info/routes (#33683)James Brooks2018-08-281-0/+3
| | |
* | | Clarify example of the test [ci skip] 黄松2018-08-251-2/+2
|/ / | | | | ActionDispatch::TestProcess::FixtureFile
* | Update ParameterFilter to yield original parametersPeter Zhu2018-08-221-6/+6
| |
* | Fix `rails routes -c` for controller name consists of multiple word.Yoshiyuki Kinjo2018-08-201-1/+1
| |
* | add missing indifferent_access require for #normalize_encode_paramsWill Jordan2018-08-161-0/+2
| | | | | | | | Fixes #33634.
* | Use `Array#extract!` where possiblebogdanvlviv2018-08-141-2/+3
| |
* | Purpose Metadata For Signed And Encrypted CookiesAssain2018-08-122-13/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Purpose metadata prevents cookie values from being copy-pasted and ensures that the cookie is used only for its originally intended purpose. The Purpose and Expiry metadata are embedded inside signed/encrypted cookies and will not be readable on previous versions of Rails. We can switch off purpose and expiry metadata embedded in signed and encrypted cookies using config.action_dispatch.use_cookies_with_metadata = false if you want your cookies to be readable on older versions of Rails.
* | Enable Start/EndWith and RegexpMatch copsBart de Water2018-07-285-10/+10
| | | | | | | | | | In cases where the MatchData object is not used, this provides a speed-up: https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
* | Merge pull request #33229 from ↵Matthew Draper2018-07-252-2/+2
|\ \ | | | | | | | | | | | | albertoalmagro/albertoalmagro/prefer-rails-command-over-bin-rails Prefer rails command over bin/rails
| * | Recommend use of rails over bin/railsAlberto Almagro2018-07-062-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed in #33203 rails command already looks for, and runs, bin/rails if it is present. We were mixing recommendations within guides and USAGE guidelines, in some files we recommended using rails, in others bin/rails and in some cases we even had both options mixed together.
* | | Rails guides are now served over httpsPaul McMahon2018-07-243-4/+4
| | | | | | | | | | | | | | | http links will be redirected to the https version, but still better to just directly link to the https version.
* | | Add implicit to path conversion to uploaded file (#28676)Aaron Kromer2018-07-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add implicit to path conversion to uploaded file Ruby has a few implicit conversion protocols (e.g. `to_hash`, `to_str`, `to_path`, etc.). These are considered implicit conversion protocols because in certain instances Ruby (MRI core objects) will check if an argument responds to the appropriate protocol and automatically convert it when it does; this is why you can provide a `Pathname` instance into `File.read` without having to explicitly call `to_s`. ```ruby a_file_path = 'some/path/file.ext' File.write a_file_path, 'String Path Content' File.read a_file_path a_pathname = Pathname(a_file_path) File.write core_file, 'Pathname Content' File.read a_file_path core_file = File.new(a_pathname) File.write core_file, 'File Content' File.read core_file tmp_file = Tempfile.new('example') File.write tmp_file, 'Tempfile Content' File.read tmp_file ``` So how does an uploaded file work in such cases? ```ruby tmp_file = Tempfile.new('example') File.write tmp_file, 'Uploaded Content' uploaded_file = ActionDispatch::Http::UploadedFile.new(tempfile: tmp_file) File.read uploaded_file ``` It fails with a `TypeError`: no implicit conversion of ActionDispatch::Http::UploadedFile into String In order to make an uploaded file work it must be explicitly converted to a file path using `path`. ```ruby File.read uploaded_file.path ``` This requires any code that expects path/file like objects to either special case an uploaded file, re-implement the path conversion protocol to use `path`, or forces the developer to explicitly cast uploaded files to paths. This last option can sometimes be difficult to do when such calls are deep within the inner workings of libraries. Since an uploaded file already has a path it makes sense to implement the implicit "path" conversion protocol (just like `File` and `Tempfile`). This change allows uploaded file content to be treated more closely to regular file content, without requiring any special case handling or explicit conversion for common file utilities. * Note uploaded file path delegation in CHANGELOG
* | | Merge pull request #32410 from yuki24/show-cause-on-debug-view-2Kasper Timm Hansen2018-07-209-62/+109
|\ \ \ | | | | | | | | Show nested exceptions on the debug view
| * | | Show nested exceptions on the debug viewYuki Nishijima2018-07-159-62/+109
| | | |
* | | | Prevent `RequestEncoder#encode_params` to parse falsey paramsAlireza Bashiri2018-07-201-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When a `get` method called with `as: :json` and `params: nil` or `params: false` (explicitly or implicitly) `RequestEncoder#encode_params` converts it into a `null` or `false` value which includes a unexpected `null=` or `false` query string into request URL. From now on `RequestEncoder#encode_params` checks whether `params` is nil or not otherwise returns. Move down `nil` conversion guard Update CHANGELOG.md
* / / Enable `Layout/EmptyLinesAroundBlockBody` to reduce review cost in the futureRyuta Kamizono2018-07-121-1/+0
|/ / | | | | | | | | | | | | We sometimes ask "✂️ extra blank lines" to a contributor in reviews like https://github.com/rails/rails/pull/33337#discussion_r201509738. It is preferable to deal automatically without depending on manpower.
* | Pass along arguments to underlying `get` method in `follow_redirect!` (#33299)Remo Fritzsche2018-07-051-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Allow get arguments for follow_redirect Now all arguments passed to `follow_redirect!` are passed to the underlying `get` method. This for example allows to set custom headers for the redirection request to the server. This is especially useful for setting headers that may, outside of the testing environment, be set automatically on every request, i.e. by a web application firewall. * Allow get arguments for follow_redirect [Remo Fritzsche + Rafael Mendonça França]
* | Merge pull request #33054 from jboler/masterRafael França2018-07-031-0/+1
|\ \ | | | | | | Fix route eager loading
| * | Only build routes simulator when there is an ASTJonathan Boler2018-06-041-0/+1
| | |
* | | Add support for more HTTP cache controlsDaniel Schierbeck2018-06-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From <https://tools.ietf.org/html/rfc5861>: > The stale-if-error HTTP Cache-Control extension allows a cache to > return a stale response when an error -- e.g., a 500 Internal Server > Error, a network segment, or DNS failure -- is encountered, rather > than returning a "hard" error. This improves availability. > > The stale-while-revalidate HTTP Cache-Control extension allows a > cache to immediately return a stale response while it revalidates it > in the background, thereby hiding latency (both in the network and on > the server) from clients. These are useful, fully standardized parts of the HTTP protocol with widespread support among CDN vendors. Supporting them will make it easier to utilize reverse proxies and CDNs from Rails.
* | | Remove reference to session_store.rb initializerJustin Searls2018-06-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Rails no longer generates this file, but Google is still packed with results suggesting it should exist, so that the doc still pointed me to it threw me off (had I deleted it or something?). Probably be better to be vague and prompt the user to stick it in a config file they own. #33124
* | | Fix bug with eager_load in development environmentDan Jensen2018-06-111-1/+1
|/ / | | | | | | | | Modifies the routes simulator to allow for empty RouteSets, which are created when secondary Engines are loaded.
* / Remove 7 years old note-to-self by tenderloveutilum2018-05-221-2/+0
|/ | | | | | Introduced in rails/journey@a806beb [ci skip]
* Merge pull request #29955 from padi/update_actiondispatch_integration_docsRyuta Kamizono2018-05-041-0/+6
|\ | | | | | | | | Updates documentation on ActionDispatch::Integration::Session#process [ci skip]
| * Updates (rdoc) documentation on ActionDispatch::Integration::Session#processMarc Rendl Ignacio2017-07-271-0/+6
| | | | | | | | | | | | Adds missing information on 2 parameters: +xhr+ and +as+ [ci skip]
* | Add support for prefetch-src directiveyuuji.yaginuma2018-05-031-0/+1
| | | | | | | | | | | | | | Specification: https://w3c.github.io/webappsec-csp/#directive-prefetch-src This directive can already be used as an experimental feature in Chrome. Ref: https://bugs.chromium.org/p/chromium/issues/detail?id=801561
* | Merge pull request #32708 from bdewater/base64-screenshotAndrew White2018-04-241-1/+1
|\ \ | | | | | | Use strict_encode64 instead of gsub newline for ScreenshotHelper
| * | Use strict_encode64 instead of gsub newline for ScreenshotHelperBart de Water2018-04-231-1/+1
| | |
* | | Use the same tag as other views to display the error messageyuuji.yaginuma2018-04-231-1/+1
|/ / | | | | | | | | | | | | | | | | Since other views use the `h2` tag, should also use `h2` on `missing_exact_template.html.erb`. https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb#L5 https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb#L11 https://github.com/rails/rails/blob/76acaf6eb9ef3635e4c6f2ca9dba34edb50f541d/actionpack/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb#L5
* | Fix Style/RedundantReturn offensesBart de Water2018-04-212-2/+2
| |
* | Merge pull request #29286 from vinistock/create_missing_exact_template_exceptionRafael Mendonça França2018-04-203-5/+29
|\ \ | | | | | | | | | Create MissingExactTemplate exception with separate template
| * | Create MissingExactTemplate exception with separate templateVinicius Stock2018-04-203-5/+29
| | |
* | | Merge pull request #32665 from albertoalmagro/fix-typos-filter-parametersRafael França2018-04-201-2/+2
|\ \ \ | | | | | | | | Fix typos related to ActionDispatch::Http::FilterParameters
| * | | [ci skip] Fix doc typos ActionDispatch::Http::FilterParametersAlberto Almagro2018-04-201-2/+2
| | | | | | | | | | | | | | | | Fixes two documentation typos found at ActionDispatch::Http::FilterParameters