docs, Cookie values are String based. Closes #12860. [ci skip]
Updated the cookie docs to use the safer JSON.{generate,parse}

cc @senny
Merge pull request #13981 from Fortisque/kevin/postgresql_reaper_threadsafe

Reaper has access to threadsafe active? call
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.

(cherry picked from commit 462d7cb3148e95c9a793d33fd882a99f0d9c57c2)

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/dispatch/routing_test.rb
Use a custom route vistor for optimized route generation

Using a Regexp to replace dynamic segments in a path string is fraught
with difficulty and can lead to odd edge cases like #13349. Since we
already have a parsed representation of the path it makes sense to use
that to generate an array of segments that can be used to build an
optimized route's path quickly.

Tests on a simple route (e.g. /posts/:id) show a speedup of 35%:
https://gist.github.com/pixeltrix/8261932

Calculating -------------------------------------
    Current Helper:       5274 i/100ms
    New Helper:           8050 i/100ms
-------------------------------------------------
    Current Helper:     79263.6 (±3.7%) i/s -     395550 in   4.997252s
    New Helper:        153464.5 (±4.9%) i/s -     772800 in   5.047834s

Tests on a more complex route show even an greater performance boost:
https://gist.github.com/pixeltrix/8261957

Calculating -------------------------------------
    Current Helper:       2367 i/100ms
    New Helper:           5382 i/100ms
-------------------------------------------------
    Current Helper:     29506.0 (±3.2%) i/s -     149121 in   5.059294s
    New Helper:         78815.5 (±4.1%) i/s -     398268 in   5.062161s

It also has the added benefit of fixing the edge cases described above.

Fixes #13349

(cherry picked from commit d017e92e1d825c6bf9fa49c339c55ca920effe45)

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/lib/action_dispatch/routing/route_set.rb
Don't create fibers just to iterate
Terminate the backend ourselves on PG 9.2+

This should make it harder to accidentally break this test.
Merge pull request #14036 from matthewd/pg_terminate_backend_4-0-stable

4-0-stable: Terminate the backend ourselves on PG 9.2+
Merge pull request #14034 from hdabrows/drop-correct-index-when-reverting-migration

Drop the correct index after reverting a migration
Conflicts:
	activerecord/CHANGELOG.md
Merge pull request #14059 from tbpgr/guides_active_support_core_ext

[Guides] fix guide active_support_core_extensions. add Note to String#indent [ci skip]
Merge pull request #14072 from robin850/patch-16

Add a missing changelog entry for #13981 and #14035
Resolve encoding issues with arrays of hstore (bug 11135).

We didn't have enough encoding for the wire protocol to store an array
of hstore types. So, further encode any hstore that is an array member.
Whilst we're here, ensure it's an HashWithIndifferentAccess being
returned, to be consistent with other serialized forms, and add testing
for arrays of hstore.

So now the following migration:

  enable_extension "hstore"
  create_table :servers do |t|
    t.string  :name
    t.hstore  :interfaces, array: true
  end

produces a model that can used like this, to store an array of hashes:

  server = Server.create(name: "server01", interfaces: [
    { name: "bge0", ipv4: "192.0.2.2", state: "up" },
    { name: "de0", state: "disabled", by: "misha" },
    { name: "fe0", state: "up" },
  ])

More at http://inopinatus.org/2013/07/12/using-arrays-of-hstore-with-rails-4/
Merge pull request #14078 from gsamokovarov/hstore_arrays_fix_4_0

Backport #13512 to 4.0 stable
Escape format, negative_format and units options of number helpers

Previously the values of these options were trusted leading to
potential XSS vulnerabilities.

Fixes: CVE-2014-0081
Correctly escape PostgreSQL arrays.

Thanks Godfrey Chan for reporting this!

Fixes: CVE-2014-0080
Preparing for 4.0.3 release
Merge branch '4-0-3' into 4-0-stable

Conflicts:
	actionpack/CHANGELOG.md
	activerecord/CHANGELOG.md
Use the reference for the mime type to get the format

Before we were calling to_sym in the mime type, even when it is unknown
what can cause denial of service since symbols are not removed by the
garbage collector.

Fixes: CVE-2014-0082
[ci skip] Close the meta tag with '/>' instead of '>'

This change fixes the 42 instances of `end tag for "meta" omitted, but
OMITTAG NO was specified` error message that comes up when the full
railsguides are validated.

Full error list at
https://gist.github.com/prakashmurthy/9086679.
Pointing to latest guides [ci skip]