aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
Commit message (Collapse)AuthorAgeFilesLines
...
* | | 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
* | | | | Introduce ActionDispatch::DebugExceptions interceptorsGenadi Samokovarov2018-04-201-1/+23
|/ / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Plugins interacting with the exceptions caught and displayed by ActionDispatch::DebugExceptions currently have to monkey patch it to get the much needed exception for their calculation. With DebugExceptions.register_interceptor, plugin authors can hook into DebugExceptions and process the exception, before being rendered. They can store it into the request and process it on the way back of the middleware chain execution or act on it straight in the interceptor. The interceptors can be play blocks, procs, lambdas or any object that responds to `#call`.
* | | | Remove unused literal introduced in #32602Andrew White2018-04-181-1/+0
| | | |
* | | | Pass nonce to CSP policy from outsideAndrew White2018-04-181-31/+24
| | | |
* | | | Output only one nonce in CSP header per requestAndrey Novikov2018-04-171-17/+30
| | | |
* | | | Fix broken nodocsChris Arcand2018-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | This commit fixes all references in the codebase missing a trailing :, which causes the nodoc not to actually work :) [skip ci]
* | | | Add WebSocket URI support to CSP DSL mappingsStephen Solis2018-04-121-1/+3
| | | |
* | | | Remove upper bound on Capybaraeileencodes2018-04-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There's no reason to block future versions of Capybara since we don't _know_ they are going to break. How will we know if we have a conservative option set? This change prevents us from blocking users who want to upgrade in the future.
* | | | Only disable headless chrome gpu on WindowsStefan Wrobel2018-04-071-1/+1
| | | | | | | | | | | | Per Chromium team this has not been necessary on other platforms for quite some time: https://bugs.chromium.org/p/chromium/issues/detail?id=737678#c1
* | | | Add changelog entry for #32446bogdanvlviv2018-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In #32446 was added method `dig` to `session`. Improve docs of method `dig`. [ci skip]
* | | | Add #dig to ActionDispatch::Request::Sessionclaudiob2018-04-041-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Summary The `session` object is not a real Hash but responds to many methods of Hash such as `[]`, `[]`, `fetch`, `has_key?`. Since Ruby 2.3, Hash also supports a `dig` method. This commit adds a `dig` method to `ActionDispatch::Request::Session` with the same behavior as `Hash#dig`. This is useful if you store a hash in your session, such as: ```ruby session[:user] = { id: 1, avatar_url: "http://example.org/nyancat.jpg" } ``` Then you can shorten your code from `session[:user][:avatar_url]` to `session.dig :user, :avatar_url`. ### Other Information I cherry-picked a commit from https://github.com/rails/rails/pull/23864, and modify a bit. The changes are below: * Converts only the first key to a string adjust to the `fetch` method. * Fixes a test case because we cannot use the indifferent access since ee5b621e2f8fde380ea4bc75b0b9d6f98499f511.
* | | | Small doc fixesT.J. Schuck2018-04-021-1/+1
| | | | | | | | | | | | | | | | [ci skip]
* | | | Make engine check more explicitAndrew White2018-03-251-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not everything that responds to `routes` is a Rails engine - for example a Grape API endpoint will have a `routes` method but can't be used with `assert_recognizes` as it doesn't respond to `recognize_path_with_request`. Fixes #32312.
* | | | Use ASCII-8BIT paths in ActionDispatch::StaticAndrew White2018-03-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The rack gem returns PATH_INFO as an ASCII-8BIT encoded string but it was being converted to US-ASCII by the match? method because it was calling Rack::Utils.escape_path. To prevent incompatibile encoding warnings use ASCII-8BIT strings for the root path and let Ruby handle any filename encoding conversion. Fixes #32294, Closes #32314.
* | | | Merge pull request #32293 from dzirtusss/fix-system-tests-transactionsEileen M. Uchitelle2018-03-211-0/+1
|\ \ \ \ | | | | | | | | | | Fix system tests transactions not closed between examples
| * | | | Fix system tests transactions not closed between examplesSergey Tarasov2018-03-191-0/+1
| | | | |
* | | | | Cache url helpers moduleAndrew White2018-03-211-1/+2
|/ / / / | | | | | | | | | | | | | | | | The urls helpers module returned by Rails.application.routes.url_helpers isn't cached so to prevent the cost of building the module cache it locally.
* | | | Check exclude before flagging cookies as secure in ActionDispatch::SSL (#32262)Catherine Khuu2018-03-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Check exclude before flagging cookies as secure. * Update comments in ActionDispatch::SSL. [Catherine Khuu + Rafael Mendonça França]
* | | | Rely on Rails::Command's help output.Kasper Timm Hansen2018-03-131-26/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We end up with: ``` Usage: bin/rails routes [options] Options: -c, [--controller=CONTROLLER] # Filter by a specific controller, e.g. PostsController or Admin::PostsController. -g, [--grep=GREP] # Grep routes by a specific pattern. -E, [--expanded], [--no-expanded] # Print routes expanded vertically with parts explained. ``` which does miss the bit about routes being printed in order. Also: * Renames options to ease help output readability, then clarifies each option. * Fixes a bunch of indentation.
* | | | Introduce `ActionDispatch::Routing::ConsoleFormatter::Base`bogdanvlviv2018-03-131-41/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Create `Base` and inherit `Sheet` and `Expanded` in order to - prevent code duplication. - Remove trailing "\n" for components of `Expanded`. - There is no need for `Expanded#header` to return `@buffer` so return `nil` instead. - Change `no_routes` message "No routes were found for this controller" since if use `-g`, it sounds incorrect. - Display `No routes were found for this controller.` if apply `-c`. - Display `No routes were found for this grep pattern.` if apply `-g`. Related to #32130
* | | | Improve docs of `ActionDispatch::Routing`bogdanvlviv2018-03-131-3/+3
| | | | | | | | | | | | | | | | | | | | - Add a mention about `-g`. - Improve info about `--expanded` option of `rails routes`.