Commit Graph

5112 Commits

Author SHA1 Message Date
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
Guilherme Cavalcanti
be93d94ef2 ActionDispatch::Http::URL.normalize_port should not strip port for protocol relative URL. 2014-05-11 12:59:37 +01:00
Aaron Patterson
314cbea9a3 just call the method and assert the return value
do not test internals
2014-05-09 12:05:24 -07:00
schneems
ca97ec5099 HTTP::Headers#key? correctly converts
Previously if you were looking for a given key, the header may incorrectly tell you that it did not exist even though it would return a valid value:

```ruby
env     = { "CONTENT_TYPE" => "text/plain" }
headers = ActionDispatch::Http::Headers.new(env)
headers["Content-Type"] 
# => "text/plain"

headers.key?("Content-Type")
# => false
```

This PR fixes that behavior by converting the key before checking for presence
2014-05-07 12:01:34 -05:00
Rafael Mendonça França
2bb008a6cf Merge pull request #14945 from tomkadwill/form_authenticity_param_refactor
Moved 'params[request_forgery_protection_token]' into its own method and...
2014-05-06 14:30:21 -03:00
Rafael Mendonça França
bdcd5f94b2 Only accept actions without File::SEPARATOR in the name.
This will avoid directory traversal in implicit render.

Fixes: CVE-2014-0130

Conflicts:
	actionpack/lib/abstract_controller/base.rb
2014-05-06 13:36:58 -03: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
5ad661e287 Use assert_raises 2014-05-04 18:47:21 -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
Guo Xiang
1f8933077d Remove tests method for test cases when controller can be inferred. 2014-05-03 23:55:23 -07: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
edogawaconan
e2ef83f838 Always escape string passed to url helper.
Makes it clear that anything passed with the helper must not be percent encoded.

Fixes previous behavior which tricks people into believing passing
non-percent-encoded will generate a proper percent-encoded path while in
reality it doesn't ('%' isn't escaped).

The intention is nice but the heuristic is broken.
2014-04-20 10:11:37 +01:00
Rafael Mendonça França
1de258e6c6 Remove wrapper div for inputs in button_to
Related with cbb917455f306cf5818644b162f22be09f77d4b2
2014-04-17 16:15:43 -03:00
Rafael Mendonça França
dd5f831f3b Update Request forgery tests to remove input wrappign div
This was changed at cbb917455f306cf5818644b162f22be09f77d4b2
2014-04-17 16:14:40 -03:00
Rafael Mendonça França
d1c5e4b28b Change the method description 2014-04-17 14:49:02 -03:00
Rafael Mendonça França
b77d10f6fe Merge pull request #14755 from timlinquist/to_io_http_upload
Use common to_io so users can access the underlying IO object
2014-04-17 14:46:45 -03:00
Tim Linquist
e601728dce Provide interface for accessing underlying IO object
In some cases users may need to work with/manipulate more of the
Tempfile api than provided by Upload. Allow users to get at the
underlying io via the common to_io method of IO/IO-like objects
2014-04-15 11:05:08 -07:00
Rafael Mendonça França
3fce111b3b Merge pull request #14745 from razum2um/plain-text-diagnostics
Display diagnostics in text format for xhr request
2014-04-15 12:51:59 -03:00
Yves Senn
81678075f8 Merge pull request #14728 from stomar/assertion-msg
Remove surplus period from assertion messages
2014-04-15 08:57:43 +02: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
Marcus Stollsteimer
ce6f472f28 Refine tests for assert_select failure messages 2014-04-14 17:40:57 +02:00
Vlad Bokov
59dbf68960 Display diagnostics in text format for xhr request 2014-04-14 20:48:13 +07:00
James Coglan
77252c332e Add a failing test for a URL helper that was broken by a6b9ea2. 2014-04-10 13:54:41 +01:00
Andriel Nuernberg
85e424de6c Avoid URI parsing
This parsing is unecessary once the Request object already has the
needed information.
2014-04-09 14:19:53 -03:00
Vipul A M
a44d7107df Remove unused subclass_controller_with_flash_type_bar var from flash test. 2014-04-07 10:34:17 +05:30
Guo Xiang Tan
8bbaa94c81 Fix setup of adding _flash_types test.
Adding flash types to a controller within any of the tests will result
in a global state change of the controller under test.

This patch will prevent state leaks and allow us to run the test in random order.
2014-04-06 13:30:49 -07:00
Boris Kuznetsov
6af07c27ae Append link to bad code to backtrace when exception is SyntaxError 2014-03-27 00:36:59 +04:00
David Heinemeier Hansson
9d44b3f886 Update test helper to use latest Digestor API 2014-03-21 19:39:08 +01:00
Attila Domokos
102c556e0b Cleaning and adding tests for Session
Adding tests for Session `destroy`, `update` and `delete` methods. No changes for code under test.
2014-03-19 21:01:08 -05:00
Aaron Patterson
ba3ad256c6 Merge pull request #14090 from Fortisque/kevin/stream_error_in_main_thread_if_not_committed
re-raise error if error occurs before committing in streaming
2014-03-17 10:49:07 -07:00
Jeremy Kemper
cbc3b89c10 Add an explicit require for 4ece124396669d3580e7f229ab407a0d4882727a rather than assume SecureRandom is available 2014-03-16 16:08:16 -07:00
Jeremy Kemper
4ece124396 Avoid concurrent test collision on the same memcache server by namespacing keys 2014-03-16 16:06:27 -07: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
Kevin Casey
933e9b4fe2 re-raise error if error occurs before committing in streaming
update the tests, using an if-else
2014-03-14 23:54:43 -07:00
Rafael Mendonça França
274d5e45e0 Merge pull request #14329 from pch/digestor-lookup-fix
Ensure LookupContext in Digestor selects correct variant
2014-03-14 14:58:34 -03:00
Łukasz Strzałkowski
f72feae9ba Don't pass variant in params, it's ignored
We're setting variant above, in request object directly
2014-03-13 17:53:11 +01:00
Aaron Patterson
3df07d093a use the body proxy to freeze headers
avoid freezing the headers until the web server has actually read data
from the body proxy.  Once the webserver has read data, then we should
throw an error if someone tries to set a header
2014-03-12 17:40:08 -07:00
Aaron Patterson
77a09218f6 only write the jar if the response isn't committed
when streaming responses, we need to make sure the cookie jar is written
to the headers before returning up the stack. This commit introduces a
new method on the response object that writes the cookie jar to the
headers as the response is committed.  The middleware and test framework
will not write the cookie headers if the response has already been
committed.

fixes #14352
2014-03-12 16:07:26 -07:00
Piotr Chmolowski
025c691536 Ensure LookupContext in Digestor selects correct variant
Related to: #14242 #14243 14293

Variants passed to LookupContext#find() seem to be ignored, so
I've used the setter instead: `finder.variants = [ variant ]`.

I've also added some more test cases for variants. Hopefully this
time passing tests will mean it actually works.
2014-03-09 08:47:17 +01:00
Andrew White
af4c9b78ff Copy shallow options from normal options when using scope
If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.
2014-03-08 19:51:06 +00:00
Andrew White
8711086f5a Pull namespace defaults out of the options hash
If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.
2014-03-08 19:51:06 +00:00
Andrew White
dcc91a04a1 Only use shallow nested scope when depth is > 1
By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.
2014-03-08 19:51:06 +00:00
Santiago Pastorino
2af7a7b19c Merge pull request #14280 from joho/make_csrf_failure_logging_optional
Make CSRF failure logging optional/configurable.
2014-03-08 15:22:42 -02:00
Prem Sichanugrist
ed88a601f7
Do note remove Content-Type when render :body
`render :body` should just not set the `Content-Type` header. By
removing the header, it breaks the compatibility with other parts.

After this commit, `render :body` will returns `text/html` content type,
sets by default from `ActionDispatch::Response`, and it will preserve
the overridden content type if you override it.

Fixes #14197, #14238

This partially reverts commit 3047376870d4a7adc7ff15c3cb4852e073c8f1da.
2014-03-05 10:33:52 -05: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
Piotr Chmolowski
1858cc6070 Variants in ActionView::Digestor
Take variants into account when calculating template digests in
ActionView::Digest.

Digestor#digest now takes a hash as an argument to support variants and
allow more flexibility in the future. Old-style arguments have been
deprecated.

Fixes #14242
2014-03-04 15:02:58 +01:00
Zachary Scott
11e815e938 Refactor tests from BaseRackTest into BaseRequestTest 2014-03-01 15:38:47 -08:00
Aaron Patterson
401787db4b make sure we wait for the threads to shut down before asserting closure 2014-02-28 16:35:33 -08:00