Commit Graph

12664 Commits

Author SHA1 Message Date
Aaron Patterson
31b3294d49 refactor content type setting
pull content-type setting to a private method to dry it up.
2015-09-08 16:14:47 -07:00
Aaron Patterson
1cc315c83c make Content-Type header the canonical location for content-type info
Instead of storing content type information in an ivar and a header,
lets move to just store the content type info in just the header.
2015-09-08 16:14:47 -07:00
Aaron Patterson
25791b46dc pull content type parsing in to a method
we'll use this method later to lazily parse content type headers.
2015-09-08 16:14:46 -07:00
Aaron Patterson
f9ff4e591e ensure that content type defaults to text / html when setting charset 2015-09-08 16:14:41 -07:00
Aaron Patterson
cd8eb351fb push content_type assigment in to metal
everything above metal really doesn't care about setting the content
type, so lets rearrange these methods to be in metal.
2015-09-08 16:14:41 -07:00
Aaron Patterson
7056e2aa18 avoid useless string allocations
_set_content_type only does something when there is a request object,
otherwise the return value of _get_content_type is always ignored. This
commit moves everything to the module that has access to the request
object so we'll never to_s unless there is a reason
2015-09-08 16:14:41 -07:00
Aaron Patterson
b42c586365 use accessors instead of manipulating the hash
in the future I would like to make the header hash read only (or at
least remove guarantees that mutations will do anything).
2015-09-08 16:14:41 -07:00
Kasper Timm Hansen
72889a6be4 Push key_generator into SerializedCookieJars
It's only used there.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
57c4a58d02 Move the request method in to the AbstractCookieJar
`CookieJar` is only at the start of the chain and has its own
request method, so we don't need it in the module.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
e05136ab41 Pull up parse to the legacy upgrading module
It was the same in both legacy versions of the signed and encrypted cookie jars.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
c9efdb582a Call super to remove the decrypt_and_verify method
The `EncryptedCookieJar` already calls it for us, so just delegate to its `parse` implementation.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
c17649e062 Call super to remove the verify method
`SignedCookieJar`'s parse method already attempts to verify the message,
so we can just call super and try the old verifier if it fails.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
39882c49dc Add parse method to share deserialization logic.
Cuts down on the duplicated reading parts.
2015-09-08 20:27:05 +02:00
Kasper Timm Hansen
94b313db8d Add commit in the EncryptedCookieJar
Gets rid of the option parsing and makes what the encryptor does stand out.
2015-09-08 20:27:04 +02:00
Kasper Timm Hansen
b807ac7a7a Use commit in the SignedCookieJar
Lets us avoid worrying about parsing the options and doing just what we need.
2015-09-08 20:27:04 +02:00
Kasper Timm Hansen
379ddf54c0 Add commit method to share option normalization
Remove the clutter to make PermanentCookieJar's one change stand out.
2015-09-08 20:27:04 +02:00
Kasper Timm Hansen
143d047d65 Add AbstractCookieJar class.
Eventually this will be the superclass of all the chained jars.
2015-09-08 20:27:04 +02:00
Rafael Mendonça França
f883867dd6 Merge pull request #21502 from bernerdschaefer/bs-polymorphic-url_for-dups-arguments
`url_for` does not modify polymorphic options
2015-09-08 13:49:22 -03:00
Jeremy Daer
f674922462 Make config.force_ssl less dangerous to try and easier to disable
SSL redirect:
* Move `:host` and `:port` options within `redirect: { … }`. Deprecate.
* Introduce `:status` and `:body` to customize the redirect response.
  The 301 permanent default makes it difficult to test the redirect and
  back out of it since browsers remember the 301. Test with a 302 or 307
  instead, then switch to 301 once you're confident that all is well.

HTTP Strict Transport Security (HSTS):
* Shorter max-age. Shorten the default max-age from 1 year to 180 days,
  the low end for https://www.ssllabs.com/ssltest/ grading and greater
  than the 18-week minimum to qualify for browser preload lists.
* Disabling HSTS. Setting `hsts: false` now sets `hsts: { expires: 0 }`
  instead of omitting the header. Omitting does nothing to disable HSTS
  since browsers hang on to your previous settings until they expire.
  Sending `{ hsts: { expires: 0 }}` flushes out old browser settings and
  actually disables HSTS:
    http://tools.ietf.org/html/rfc6797#section-6.1.1
* HSTS Preload. Introduce `preload: true` to set the `preload` flag,
  indicating that your site may be included in browser preload lists,
  including Chrome, Firefox, Safari, IE11, and Edge. Submit your site:
    https://hstspreload.appspot.com
2015-09-07 17:57:20 -07:00
Marcin Olichwirowicz
81bc771e7c Remove mocha from ActionPack tests 2015-09-05 16:58:40 +02:00
Aaron Patterson
a8f4568f53 implement abstract store methods
converts old ID methods to the new abstract store methods in Rack
2015-09-04 19:25:59 -07:00
Aaron Patterson
bcfa2a0d5e stop using deprecated Abstract::ID class 2015-09-04 18:58:49 -07:00
Aaron Patterson
529136d670 stop inheriting from Rack::Request
Just include the modules necessary in the Request object to implement
the things we need.  This should make it easier to build delegate
request objects because the API is smaller
2015-09-04 17:37:22 -07:00
Aaron Patterson
e25fdad2f1 use Rack::Utils.unescape_path to unescape paths
Escaping and unescaping paths is different than query parameters, and we
need to respect that.  This commit uses the new method in Rack to escape
and unescape paths.  Fixes #11816
2015-09-04 14:43:46 -07:00
Bernerd Schaefer
ee63532d40 url_for does not modify polymorphic options
The `url_for` methods in `actionpack` and `actionview`
now make a copy of the provided options
before generating polymorphic paths or URLs.

The bug in the previous behavior
is most noticeable in a case like:

    url_options = [:new, :post, param: 'value']

    if current_page?(url_options)
      css_class = "active"
    end

    link_to "New Post", url_options, class: css_class
2015-09-04 13:42:32 -07:00
Eileen M. Uchitelle
0294c61359 Merge pull request #21483 from justanshulsharma/add-ip6-address
[ci skip] Added localhost IPv6
2015-09-03 04:37:10 -04:00
Anshul Sharma
9567ba737f [ci skip] Added localhost IPv6 2015-09-03 14:02:52 +05:30
eileencodes
ec14aad419 Fix route creation when format is a blank string
Commit bff61ba, while reducing allocations, caused a regression when an empty
format is passed to a route.

This can happen in cases where you're using an anchor tag, for example:
`https://example.com/parent/575256966.#child_1032289285`.

Because of this change `format` was getting sent in
`parameterized_parts` when previously it was not included. This resulted
in blank `format`'s being returned as `.` when if there was an extension
included it would be `.extension`. Since there was no extension this
caused incorrect URL's.

The test shows this would result in `/posts/show/1.` instead of
`/posts/show/1` which causes bad urls since the format is not present.
2015-09-02 09:18:46 -04:00
kishore-mohan
cf82b2e034 typo "description not clear corrected with proper description and action_controller_overview file Rails' -> Rails" [ci skip] 2015-09-02 09:19:47 +05:30
Marcin Olichwirowicz
b69699afda Remove not used requires 2015-09-01 20:36:47 +02:00
eileencodes
75a121a2c5 Fix bug where cookies mutated by request were not persisted
With changes made in 8363b8 and ae29142 cookies that are mutated on the
request like `cookies.signed = x` were not retained in subsequent tests,
breaking cookie authentiation in controller tests.

The test added demonstrates the issue.

The reason we need to select from non-deleted cookies is because without
checking the `@delete_cookies` the `cookie_jar` `@cookies` will send the
wrong cookies to be updated. The code must check for `@deleted_cookies`
before sending an `#update` with the requests cookie_jar cookies.
This follows how the cookie_jar cookies from the request were updated
before these changes.
2015-09-01 08:42:30 -04:00
Rafael Mendonça França
c47c1d206e Merge pull request #19788 from cmdrclueless/actionpack_http_url_ipv6
Fix broken IPv6 addresses handling
2015-09-01 01:32:54 -03:00
Rafael Mendonça França
74b23b9e4b Merge pull request #21298 from rodzyn/remove_dead_code
Remove dead code
2015-09-01 00:50:35 -03:00
Aaron Patterson
49ba2710e9 add a method for getting the http auth salt 2015-08-29 18:11:36 -07:00
Aaron Patterson
e5e2bbdc53 env to get_header conversion 2015-08-29 18:09:14 -07:00
Xavier Noria
61b737671a fixes example for consistency [ci skip] 2015-08-29 14:28:16 +02:00
Xavier Noria
b7bd4d9f26 swaps words [ci skip] 2015-08-29 14:24:56 +02:00
Xavier Noria
eefb6db4a9 revamps the docs of strong params require [ci skip]
References #19565.
2015-08-29 14:20:45 +02:00
akihiro17
2de60a926b Set the content-type to text/html if the options[:html] is true
In this commit, we set the content-type to `text/html` in AbstractController if the `options[:html]` is true so that we don't include ActionView::Rendering into ActionController::Metal to set it properly.

I removed the if `options[:plain]` statement because `AbstractController#rendered_format` returns `Mime::TEXT` by default.
2015-08-29 01:02:43 +09:00
Xavier Noria
cbe7899f9d revises 877e42e
* A string in the example lacked quotes.

* The tests asserted stuff about :last_name, whereas
  test params do not have that key.

* But, the first one passed, why? After hitting my head against
  the wall and doing some obscure rituals realized the new
  #require had an important typo, wanted to iterate over the
  array argument (key), but it ran over its own hash keys
  (method #keys).

* Modified the test to prevent the same typo to happen again.

* The second test assigned to an unused variable safe_params
  that has been therefore removed.

* Grammar of the second test description.

* Since I was on it, reworded both test descriptions.
2015-08-28 17:15:20 +02:00
Gaurish Sharma
877e42e232 [Feature] params.require requires array of params
This PR adds ability to accept arrays which allows you to require multiple values in one method. so instead of this:

```ruby
params.require(:person).require(:first_name)
params.require(:person).require(:last_name)
```

Here it will be one line for each params, so say if I require 10params, it will be 10lines of repeated code which is not dry. So I have added new method which does this in one line:

```ruby
params.require(:person).require([:first_name, :last_name])
```

Comments welcome
2015-08-28 18:02:13 +05:30
Guillermo Iguaran
3cc7b0a239 Merge pull request #21396 from rodzyn/code-cleanup
Code cleanup
2015-08-28 00:45:44 -05:00
Aaron Patterson
bf203e471b Revert "this always sets :public to false, so just do that"
This reverts commit cae2b5bb59212961c4a35c939381ebece48d1177.

I am an idiot.
2015-08-27 14:16:01 -07:00
Aaron Patterson
cae2b5bb59 this always sets :public to false, so just do that 2015-08-27 13:47:37 -07:00
Aaron Patterson
d05d7e23d1 remove dependency on @cache_control ivar
eventually we'll remove this instance variable, but this is the first
step
2015-08-27 12:09:04 -07:00
Aaron Patterson
53265e8806 remove @etag ivar
we're storing the value in the headers hash, so lets just store the
value in one place.
2015-08-27 12:02:33 -07:00
Aaron Patterson
4e88f4f808 use the abstract API in modules
Modules should be using the API that the abstract modules use so that we
can move these modules between implementations
2015-08-27 12:00:56 -07:00
Aaron Patterson
f597dc5cf6 remove useless conditional
cookies are always stored as a string in the header hash, so it will not
need to be joined.
2015-08-27 11:38:52 -07:00
Aaron Patterson
14af136371 implement the API required by the abstract Rack request. 2015-08-27 11:13:11 -07:00
Aaron Patterson
97d088ebf2 use the non-hash dependent Rack utils API
eventually we will refactor this to not know about header hashes
2015-08-27 11:13:10 -07:00