Commit Graph

483 Commits

Author SHA1 Message Date
Aaron Patterson
93fb4c1e62 Merge branch 'rosetta_flash' of https://github.com/gcampbell/rails into gcampbell-rosetta_flash
* 'rosetta_flash' of https://github.com/gcampbell/rails:
  Address CVE-2014-4671 (JSONP Flash exploit)

Conflicts:
	actionpack/CHANGELOG.md
2014-07-10 10:20:16 -07:00
Karl Entwistle
8a29713134 Force encoding of US-ASCII to UTF-8 in unescape_uri.
Because URI paths may contain non US-ASCII characters we need to force
the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
This essentially replicates the functionality of the monkey patch to
URI.parser.unescape in active_support/core_ext/uri.rb.

Fixes #16104.
2014-07-10 10:02:11 +01:00
Greg Campbell
4003a5bd76 Address CVE-2014-4671 (JSONP Flash exploit)
Adds a comment before JSONP callbacks. See
http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ for more
details on the exploit in question.
2014-07-09 11:37:19 -07:00
Seb Jacobs
e972d34120 Generate shallow paths for all children of shallow resources.
Prior to this commit shallow resources would only generate paths for
non-direct children (with a nested depth greater than 1).

Take the following routes file.

    resources :blogs do
      resources :posts, shallow: true do
        resources :comments do
          resources :tags
        end
      end
    end

This would generate shallow paths for `tags` nested under `posts`,
e.g `/posts/:id/tags/`, however it would not generate shallow paths
for `comments` nested under `posts`, e.g `/posts/:id/comments/new`.

This commit changes the behaviour of the route mapper so that it
generate paths for direct children of shallow resources, for example
if you take the previous routes file, this will now generate
shallow paths for `comments` nested under `posts`, .e.g
`posts/:id/comments/new`.

This was the behaviour in Rails `4.0.4` however this was broken in
@jcoglan's fix for another routes related issue[1].

This also fixes an issue[2] reported by @smdern.

[1] https://github.com/rails/rails/commit/d0e5963
[2] https://github.com/rails/rails/issues/15783
2014-07-06 08:52:32 +01:00
Lucas Mazza
b00b638b95 Change the JSON renderer to enforce the 'JS' Content Type
The controller can set the response format as 'JSON' before the renderer code be
evaluated, so we must replace it when necessary.

Fixes #15081
2014-07-02 20:02:00 -03:00
Rafael Mendonça França
ebdedaec32 Merge pull request #15933 from rafael/master
Add always permitted parameters as a configurable option.

[Rafael Mendonça França + Gary S. Weaver]
2014-06-27 18:16:52 -03:00
Larry Lv
4a9d4c85c3 Fix request's path_info when a rack app mounted at '/'.
Fixes issue #15511.
2014-06-14 04:57:33 +08:00
Matthew Draper
497def80b5 Merge pull request #15692 from sromano/falseClass
ActionController::Parameters#require now accepts FalseClass values
2014-06-14 06:14:19 +09:30
Sergio Romano
540d153531 ActionController::Parameters#require now accepts FalseClass values
Fixes #15685.
2014-06-13 14:42:38 -03:00
Larry Lv
fdb1059795 Fix parsed token value with header Authorization token=. 2014-06-13 16:29:15 +08:00
Matthew Draper
6a89850dfe Handle client disconnect during live streaming
.. even when the producer is blocked for a write.
2014-06-08 07:21:14 +09:30
Rafael Mendonça França
489a8f2a44 Partially revert deprecation of *_filter
We are going to deprecate only on Rails 5 to make easier plugin
maintainers support different Rails versions. Right now we are only
discouraging their usage.

This reverts commit 6c5f43bab8206747a8591435b2aa0ff7051ad3de.

Conflicts:
	actionpack/CHANGELOG.md
2014-06-03 19:53:28 -03:00
Aaron Patterson
cc26b6b7bc Routes specifying 'to:' must be a string that contains a "#" or a rack
application.  Use of a symbol should be replaced with `action: symbol`.
Use of a string without a "#" should be replaced with `controller: string`.
2014-06-03 14:05:42 -07:00
Zachary Scott
84d956e3f4 Missing period from AP/CHANGELOG [ci skip] 2014-05-31 11:21:56 -07:00
Rafael Mendonça França
6c5f43bab8 Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e04838f01f5589fa50b0baa480d60c815e2c
2014-05-27 19:10:14 -03:00
Rafael Mendonça França
ade105be40 Merge pull request #14986 from dlangevin/trailing-slash-url-generation
Fixes URL generation with trailing_slash: true

Conflicts:
	actionpack/lib/action_dispatch/http/url.rb
2014-05-24 12:41:28 -03:00
Zachary Scott
1d7b3fa84c Future port c8ddb61 2014-05-23 14:45:21 -07:00
Dan Langevin
82b4d879bf Fixes URL generation with trailing_slash: true
URL generation with trailing_slash: true was adding a trailing slash
after .:format

    Routes.draw do
      resources :bars
    end

    bars_url(trailing_slash: true, format: 'json')
      # => /bars.json/

This commit removes that extra trailing slash
2014-05-22 16:03:52 -04:00
Guo Xiang Tan
4fd144dd4b Form full URI as string to be parsed in Rack::Test.
There are performance gains to be made by avoiding URI setter methods.
2014-05-21 23:17:17 -07:00
Rafael Mendonça França
16a8a68b7e Merge pull request #15118 from khelben/head_with_status_action_stack_level_too_deep
fixes stack level too deep exception on action named 'status' rendering 'head :ok'
2014-05-15 16:18:37 -03:00
Christiaan Van den Poel
20fece1491 fixes stack level too deep exception on action named 'status' returning 'head :ok' 2014-05-15 21:14:46 +02:00
Rafael Mendonça França
cf50bbd68c Merge pull request #15121 from skarpesh/rfc4791-methods
Add RFC 4791 MKCALENDAR method
2014-05-15 14:37:35 -03:00
kasper
42728c70ee Add RFC4791 MKCALENDAR method 2014-05-15 17:41:37 +03:00
Rafael Mendonça França
f2bff250a0 Merge pull request #14137 from dasch/better-fragment-cache-instrumentation
Add controller and action name to the fragment caching instrumentation payload

Conflicts:
	actionpack/CHANGELOG.md
2014-05-14 20:04:43 -03:00
Andrew White
2378f69e69 Always use the provided port for protocol relative urls
There may be situations where you need to tunnel SSL connections over
port 80 so we shouldn't remove it if it has been explicitly provided.
2014-05-11 12:59:37 +01:00
Daniel Schierbeck
92fbbf67e3 Add controller and action name to the instrumentation payload 2014-05-10 09:35:29 +00:00
Tom Kadwill
7d5a858e5c Moved 'params[request_forgery_protection_token]' into its own method and improved tests. 2014-05-06 14:58:30 +01:00
Rafael Mendonça França
e918516d2f Improve CHANGELOG entry 2014-05-04 18:47:29 -03:00
Rafael Mendonça França
95ab4fd6b7 Merge pull request #11166 from xavier/callable_constraint_verification
Callable route constraint verification

Conflicts:
	actionpack/CHANGELOG.md
2014-05-04 18:42:20 -03:00
Rafael Mendonça França
b638c1a0b3 Merge pull request #12651 from cespare/ipv6-remote-ip-fixes
Make remote_ip detection properly handle private IPv6 addresses

Conflicts:
	actionpack/CHANGELOG.md
2014-05-01 14:43:14 -03:00
Godfrey Chan
2a412b3d6f Fixed an issue with migrating legacy json cookies.
Previously, the `VerifyAndUpgradeLegacySignedMessage` assumes all incoming
cookies are marshal-encoded. This is not the case when `secret_token` is
used in conjunction with the `:json` or `:hybrid` serializer.

In those case, when upgrading to use `secret_key_base`, this would cause a
`TypeError: incompatible marshal file format` and a 500 error for the user.

Fixes #14774.

*Godfrey Chan*
2014-04-23 12:32:14 -05:00
Andrew White
5460591f02 Make URL escaping more consistent
1. Escape '%' characters in URLs - only unescaped data
   should be passed to URL helpers

2. Add an `escape_segment` helper to `Router::Utils`
   that escapes '/' characters

3. Use `escape_segment` rather than `escape_fragment`
   in optimized URL generation

4. Use `escape_segment` rather than `escape_path`
   in URL generation

For point 4 there are two exceptions. Firstly, when a route uses wildcard
segments (e.g. *foo) then we use `escape_path` as the value may contain '/'
characters. This means that wildcard routes can't be optimized. Secondly,
if a `:controller` segment is used in the path then this uses `escape_path`
as the controller may be namespaced.

Fixes #14629, #14636 and #14070.
2014-04-20 10:11:38 +01:00
Rafael Mendonça França
c91a531ff3 Add CHANGELOG entry for #14755 [ci skip] 2014-04-17 14:50:52 -03:00
Rafael Mendonça França
4d21e496e1 Return null type format when format is not know
When requesting a controller with the following code with a unknown format:

    def my_action
      respond_to do |format|
        format.json { head :ok }
        format.any { render text: 'Default response' }
      end
    end

we should render the default response instead of raising ActionController::UnknownFormat

Fixes #14462

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/mime/respond_with_test.rb

Conflicts:
	actionpack/CHANGELOG.md
2014-04-14 17:10:11 -03:00
Rafael Mendonça França
f1a4f0a494 Add CHANGELOG entry for #14619 [ci skip] 2014-04-11 11:27:41 -03:00
Andrew White
e10f26f9e9 Only make deeply nested routes shallow when parent is shallow
Since `:shallow` may be set at any point in the resource nesting we should
only make the new and collection routes shallow when the parent is shallow.

This is a bit of a hack but until the mapper is refactored to an object graph
instead of a hash of merged values it's the best we can do.

Fixes #14684.
2014-04-11 10:20:54 +01:00
Boris Kuznetsov
6af07c27ae Append link to bad code to backtrace when exception is SyntaxError 2014-03-27 00:36:59 +04:00
Vishal Lal
0ebae1dbc5 Swapped parameters of assert_equal in assert_select 2014-03-22 22:58:37 +00:00
Andrew White
bb0518891c Use nested_scope? not shallow? to determine whether to copy options
The method `shallow?` returns false if the parent resource is a singleton so
we need to check if we're not inside a nested scope before copying the :path
and :as options to their shallow equivalents.

Fixes #14388.
2014-03-16 09:35:35 +00:00
Carlos Antonio da Silva
45efd0ebf7 Move changelog entry to the top, highlight module name [ci skip] 2014-03-08 18:20:45 -03:00
John Barton (joho)
67584c6ae3 Make CSRF failure logging optional/configurable.
Added the log_warning_on_csrf_failure option to ActionController::RequestForgeryProtection
which is on by default.
2014-03-05 11:31:57 +11:00
Tony Wooster
a351149e80 Fix controller test not resetting @_url_options
Commit 4f2cd3e9 introduced a bug by reordering the call to
`@controller.recycle!` above the call to `build_request_uri`. The
impact of this was that the `@_url_options` cache ends up not being
reset between building a request URI (occurring within the test
controller) and the firing of the actual request.

We encountered this bug because we had the following setup:

  class MinimumReproducibleController < ActionController::Base
    before_filter { @param = 'param' }

    def index
      render text: url_for(params)
    end

    def default_url_options
      { custom_opt: @param }
    end
  end

  def test_index
    get :index # builds url, then fires actual request
  end

The first step in  `get :index` in the test suite would populate the
@_url_options cache. The subsequent call to `url_for` inside of the
controller action would then utilize the uncleared cache, thus never
calling the now-updated default_url_options.

This commit fixes this bug calling recycle! twice, and removes a call
to set response_body, which should no longer be needed since we're
recycling the request object explicitly.
2014-02-26 10:39:44 -08:00
Carlos Antonio da Silva
71b3910a7d Point master changelogs to 4-1-stable branch
Remove 4-1 related entries from master [ci skip]
2014-02-25 09:14:36 -03:00
Prem Sichanugrist
920f3ba266 Introduce render :html for render HTML string
This is an option for to HTML content with a content type of
`text/html`. This rendering option calls `ERB::Util.html_escape`
internally to escape unsafe HTML string, so you will have to mark your
string as html safe if you have any HTML tag in it.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
8cd9f6d205 Introduce render :plain for render plain text
This is as an option to render content with a content type of
`text/plain`. This is the preferred option if you are planning to render
a plain text content.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
103e18c87d Introduce render :body for render raw content
This is an option for sending a raw content back to browser. Note that
this rendering option will unset the default content type and does not
include "Content-Type" header back in the response.

You should only use this option if you are expecting the "Content-Type"
header to not be set. More information on "Content-Type" header can be
found on RFC 2616, section 7.2.1.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Kevin Casey
8508346dd0 Correct prestreaming controller response status.
if the controller action has not yet streamed any data, actions should
process as normal, and errors should trigger the appropriate behavior
(500, or in the case of ActionController::BadRequest, a 400 Bad Request)
2014-02-15 13:05:00 -08:00
Godfrey Chan
0b86a6e950 Updated CHANGELOG, docs, guides and release notes.
Also added a `cookies_serializer.rb` initializer to the app template.
2014-02-11 02:52:07 -08:00
Godfrey Chan
ecf04f19b0 Added changelog entry for Flash changes [ci skip] 2014-02-11 01:54:58 -08:00
Andrew White
462d7cb314 Set the :shallow_path as each scope is generated
If we set :shallow_path when shallow is called it can result in incorrect
paths if the resource is inside a namespace because namespace itself sets
the :shallow_path option to the namespace path.

We fix this by removing the :shallow_path option from shallow as that should
only be turning shallow routes on and not otherwise affecting the scope.
To do this we need to treat the :shallow option to resources differently to
other scope options and move it to before the nested block is called.

This change also has the positive side effect of making the behavior of the
:shallow option consistent with the shallow method.

Fixes #12498.
2014-02-09 10:46:07 -08:00