Commit Graph

5363 Commits

Author SHA1 Message Date
Aaron Patterson
c6f9518e24 Merge branch 'master-sec'
* master-sec:
  FileHandler should not be called for files outside the root
2014-10-30 11:39:46 -07:00
Godfrey Chan
aa1fadd48f Deprecate the only_path option on *_path helpers.
In cases where this option is set to `true`, the option is redundant and can
be safely removed; otherwise, the corresponding `*_url` helper should be
used instead.

Fixes #17294.

See also #17363.

[Dan Olson, Godfrey Chan]
2014-10-28 09:43:33 -07:00
Rafael Mendonça França
d27efbfbf5 Merge pull request #17362 from bronzle/fix_debug_exceptions_app
Show the user’s application in the source window and select the correct ...
2014-10-26 22:04:43 -05:00
Xavier Noria
8d7cf75684 give a better error message for misspelled helpers
See comment in this patch for the rationale.

References #16468
2014-10-25 14:06:33 +02:00
Byron Bischoff
dbcbbcf2bc Show the user’s application in the source window and select the correct trace list, closes #17312 2014-10-23 09:53:43 -07:00
Accessd
20dcc0ab0a fix small typo in routing test 2014-10-21 19:46:29 +04:00
Accessd
2224bf7992 fix url generation error message 2014-10-21 12:10:48 +04:00
Nicolas Cavigneaux
3041bb2a94 Improve Journey compliance to RFC 3986
The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
2014-10-14 16:42:50 +02:00
Arthur Neves
707e2e8858 Add regression test for router was overwriting PATH_INFO
[related #17233]
2014-10-10 19:05:36 -04:00
Aaron Patterson
d1123f2056 FileHandler should not be called for files outside the root
FileHandler#matches? should return false for files that are outside the
"root" path.
2014-10-10 16:00:03 -07:00
Stefan Henzen
e86cadc257 Request#check_method no longer breaks when :en is not available locale
Request#check_method would use to_sentence(locale: :en), which breaks when
I18n.available_locales does not include :en and
I18n.enforce_available_locales is true (default).

Inlined to_sentence functionality to solve this.
2014-10-09 15:45:49 +02:00
Kasper Timm Hansen
f939904f23 Parse HTML as document fragment.
This is to match the changes in Rails Dom Testing rails/rails-dom-testing#20.
2014-09-29 21:41:52 +02:00
Erik Michaels-Ober
e2b49b203f Use Hash#each_key instead of Hash#keys.each
Hash#keys.each allocates an array of keys; Hash#each_key iterates through the
keys without allocating a new array. This is the reason why Hash#each_key
exists.
2014-09-29 17:27:10 +02:00
Rafael Mendonça França
4af5899e25 Revert "Merge pull request #16966 from why-el/symbolize-path-params"
This reverts commit 9d05d6de52871e57bfbf54a60de005e8a5f5b0e4, reversing
changes made to 0863c9248fd47a15e88e05ce4fcd80966684c0e3.

The change in the behaviour reported at #16958 doesn't exist since 4.0
and 4.1 works in the same way
2014-09-25 18:07:22 -03:00
Mohamed Wael Khobalatte
f10b38bbc8 Ensure named path params are symbols (Fixes #16958) 2014-09-25 17:40:26 -03:00
Godfrey Chan
391cfc2054 Fix actionpack test cases broken by #16888 2014-09-26 01:42:18 +09:00
Yuki Nishijima
75eaefcc2f Rescue Rack::Utils::ParameterTypeError instead of TypeError
As of rack/rack@167b648023, Rack raises
Rack::Utils::ParameterTypeError which inherits TypeError.

In terms of the behavior, Rescuing TypeError still works but this
method shouldn't rescue if TypeError is raised for other reasons.
2014-09-13 16:54:20 -07:00
Godfrey Chan
2b41343c34 Default to sorting user's test cases for now
Goals:

1. Default to :random for newly generated applications
2. Default to :sorted for existing applications with a warning
3. Only show the warning once
4. Only show the warning if the app actually uses AS::TestCase

Fixes #16769
2014-09-08 05:32:16 -07:00
Thiago Pradi
90c06717bc Removing unused fake models 2014-09-07 22:51:14 -03:00
Javan Makhmali
66f8997671 Add support for Rack::ContentLength middelware 2014-09-06 12:33:29 -04:00
Jeremy Kemper
2a78d6f561 Deprecate implicit AD::Response splatting and Array conversion 2014-09-06 07:05:59 -07:00
Rafael Mendonça França
67117f7c5d Add test to assert_recognizes with custom message 2014-09-05 16:47:00 -03:00
Rafael Mendonça França
3f720d580f Merge pull request #14911 from estsauver/14908
Propagate test messages through assert_routing helper, Fixes #14908
2014-09-05 16:43:14 -03:00
Matthew Draper
2f52f96988 Leave all our tests as order_dependent! for now
We're seeing too many failures to believe otherwise.

This reverts commits bc116a55ca3dd9f63a1f1ca7ade3623885adcc57,
cbde413df3839e06dd14e3c220e9800af91e83ab,
bf0a67931dd8e58f6f878b9510ae818ae1f29a3a, and
2440933fe2c27b27bcafcd9019717800db2641aa.
2014-09-02 23:55:34 +09:30
Xavier Noria
4c917dae9a Merge pull request #16644 from Agis-/drb-tests-actionpack-vagrant
Use system /tmp for temp files when testing actionpack
2014-08-30 09:49:13 +02:00
Aaron Patterson
6d86762fd8 Merge pull request #16637 from Agis-/redirect-with-constraint-route
Fix the router ignoring constraints when used together with a redirect route
2014-08-28 10:33:40 -07:00
schneems
0b1a87f73c Refactor out Dir.glob from ActionDispatch::Static
Dir.glob can be a security concern. The original use was to provide logic of fallback files. Example a request to `/` should render the file from `/public/index.html`. We can replace the dir glob with the specific logic it represents. The glob {,index,index.html} will look for the current path, then in the directory of the path with index file and then in the directory of the path with index.html. This PR replaces the glob logic by manually checking each potential match. Best case scenario this results in one less file API request, worst case, this has one more file API request.

Related to #16464

Update: added a test for when a file of a given name (`public/bar.html` and a directory `public/bar` both exist in the same root directory. Changed logic to accommodate this scenario.
2014-08-27 13:03:08 -05:00
Peter Suschlik
03e660e768 Use less iterations for KeyGenerator in tests
This commit improves performance of cookie tests:

Ruby  |   After  |   Before
----- | --------:| --------:
MRI   |    5.03s |     9.28s
JRuby |   25.45s |  1648.23s

Please note the improvement for JRuby.
2014-08-27 11:34:17 +02:00
Agis-
d78f3f0ec3 Don't ignore constraints in redirect routes
402c2af550
introduced a regression that caused any constraints added to redirect routes
to be ignored.

Fixes #16605
2014-08-25 00:18:25 +03:00
schneems
8e31fa3b72 Address comments on Gzip implementation
- don't mutate PATH_INFO in env, test
- test fallback content type matches Rack::File
- change assertion style
- make HTTP_ACCEPT_ENCODING comparison case insensitive
- return gzip path from method instead of true/false so we don't have to assume later
- don't allocate un-needed hash.

Original comments:

https://github.com/rails/rails/commit/
cfaaacd9763642e91761de54c90669a88d772e5a#commitcomment-7468728

cc @jeremy
2014-08-24 15:58:16 -05:00
Agis-
b7ab73a4e2 Use system /tmp when testing actionpack
c64bff2c87
added support and enabled parallel execution of the actionpack tests.

However it introduced c64bff2c87
since one cannot connect to a socket file that's inside a Vagrant synced folder
due to security restrictions, and DRb tries to.

Also rename the temporary files to make it obvious that they're rails-related,
since now they're placed outside the project's directory.

Fixes c64bff2c87
2014-08-22 22:03:41 +03:00
Guo Xiang Tan
9212042631 Improve router test.
We should assert that routes will not be recognized if the verbs do
not match.
2014-08-21 16:35:39 +08:00
Guo Xiang Tan
d3eb92d95a Avoid duplicating routes for HEAD requests.
Follow up to rails#15321

Instead of duplicating the routes, we will first match the HEAD request to
HEAD routes. If no match is found, we will then map the HEAD request to
GET routes.
2014-08-21 16:35:39 +08:00
schneems
cfaaacd976 Enable gzip compression by default
If someone is using ActionDispatch::Static to serve assets and makes it past the `match?` then the file exists on disk and it will be served. This PR adds in logic that checks to see if the file being served is already compressed (via gzip) and on disk, if it is it will be served as long as the client can handle gzip encoding. If not, then a non gzip file will be served.

This additional logic slows down an individual asset request but should speed up the consumer experience as compressed files are served and production applications should be delivered with a CDN. This PR allows a CDN to cache a gzip file by setting the `Vary` header appropriately. In net this should speed up a production application that are using Rails as an origin for a CDN. Non-asset request speed is not affected in this PR.
2014-08-20 22:33:06 -05:00
Jeremy Kemper
79d50ce310 Merge pull request #16570 from bradleybuda/breach-mitigation-mask-csrf-token
CSRF token mask from breach-mitigation-rails gem
2014-08-19 18:17:07 -07:00
Bradley Buda
69fc0e1b5e Auth token mask from breach-mitigation-rails gem
This merges in the code from the breach-mitigation-rails gem that masks
authenticity tokens on each request by XORing them with a random set of
bytes. The masking is used to make it impossible for an attacker to
steal a CSRF token from an SSL session by using techniques like the
BREACH attack.

The patch is pretty simple - I've copied over the [relevant
code](https://github.com/meldium/breach-mitigation-rails/blob/master/lib/breach_mitigation/masking_secrets.rb)
and updated the tests to pass, mostly by adjusting stubs and mocks.
2014-08-19 15:28:07 -07:00
Rafael Mendonça França
d59a24d543 Protect against error when parsing parameters with Bad Request
Related with #11795.
2014-08-19 15:36:05 -03:00
Prem Sichanugrist
3591dd59e0 Fix failing test on several methods on Parameter
* `each`
* `each_pair`
* `delete`
* `select!`
2014-08-18 20:42:46 -04:00
Prem Sichanugrist
0663e8f179 Seperate Parameters accessors and mutators tests 2014-08-18 20:42:46 -04:00
Prem Sichanugrist
bd7f47190e Add missing Hash methods to AC::Parameters
This is to make sure that `permitted` status is maintained on the
resulting object.

I found these methods that needs to be redefined by looking for
`self.class.new` in the code.

* extract!
* transform_keys
* transform_values
2014-08-18 20:42:45 -04:00
Prem Sichanugrist
5109740c6b Make AC::Params#to_h return Hash with safe keys
`ActionController::Parameters#to_h` now returns a `Hash` with
unpermitted keys removed. This change is to reflect on a security
concern where some method performed on an `ActionController::Parameters`
may yield a `Hash` object which does not maintain `permitted?` status.
If you would like to get a `Hash` with all the keys intact, duplicate
and mark it as permitted before calling `#to_h`.

    params = ActionController::Parameters.new(name: 'Senjougahara Hitagi')
    params.to_h # => {}

    unsafe_params = params.dup.permit!
    unsafe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

    safe_params = params.permit(:name)
    safe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

This change is consider a stopgap as we cannot chage the code to stop
`ActionController::Parameters` to inherit from
`HashWithIndifferentAccess` in the next minor release.

Also, adding a CHANGELOG entry to mention that
`ActionController::Parameters` will not inheriting from
`HashWithIndifferentAccess` in the next major version.
2014-08-18 20:42:45 -04:00
Akira Matsuda
b30b99c615 Expectations first 2014-08-18 15:40:53 +09:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
Godfrey Chan
e158ee50e6 Use AS::JSON for (de)serializing cookies
Use the Active Support JSON encoder for cookie jars using the `:json` or
`:hybrid` serializer. This allows you to serialize custom Ruby objects into
cookies by defining the `#as_json` hook on such objects.

Fixes #16520.
2014-08-17 12:41:42 -07:00
Godfrey Chan
a485633b16 responders 1.x won't do it. Told you to RTFM for details! 2014-08-17 12:19:23 -07:00
Godfrey Chan
b662273df3 The gem is called 'responders' 2014-08-17 11:58:17 -07:00
Godfrey Chan
24226c51f0 Raise a more helpful error for people who are using these extracted features 2014-08-17 11:54:09 -07:00
Godfrey Chan
69ed422a9c Fixed broken reference caused by 14965ba 2014-08-17 11:44:31 -07:00
Godfrey Chan
beff925c32 Merge pull request #16467 from strzalek/cookies-digest-config-option2
Cookies digest config option (pt. 2)

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/lib/action_dispatch/middleware/cookies.rb
2014-08-17 11:23:14 -07:00
José Valim
57f5b00ba4 Remove more references to respond_with 2014-08-17 13:20:23 -04:00