aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md33
-rw-r--r--actionpack/lib/action_dispatch/middleware/cookies.rb2
-rw-r--r--actionpack/lib/action_dispatch/railtie.rb3
-rw-r--r--actionpack/lib/action_view/helpers/asset_url_helper.rb2
-rw-r--r--actionpack/lib/action_view/helpers/tag_helper.rb7
-rw-r--r--actionpack/lib/action_view/helpers/tags/collection_helpers.rb3
-rw-r--r--actionpack/lib/action_view/helpers/url_helper.rb2
-rw-r--r--actionpack/lib/action_view/template.rb2
-rw-r--r--actionpack/test/dispatch/response_test.rb4
-rw-r--r--actionpack/test/template/asset_tag_helper_test.rb7
-rw-r--r--actionpack/test/template/dependency_tracker_test.rb2
-rw-r--r--actionpack/test/template/form_collections_helper_test.rb16
-rw-r--r--actionpack/test/template/tag_helper_test.rb4
-rw-r--r--actionpack/test/template/url_helper_test.rb5
14 files changed, 75 insertions, 17 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 6f5027dc23..b1c5987fe4 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,3 +1,36 @@
+* Use a case insensitive URI Regexp for #asset_path.
+
+ This fix a problem where the same asset path using different case are generating
+ different URIs.
+
+ Before:
+
+ image_tag("HTTP://google.com")
+ # => "<img alt=\"Google\" src=\"/assets/HTTP://google.com\" />"
+ image_tag("http://google.com")
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
+
+ After:
+
+ image_tag("HTTP://google.com")
+ # => "<img alt=\"Google\" src=\"HTTP://google.com\" />"
+ image_tag("http://google.com")
+ # => "<img alt=\"Google\" src=\"http://google.com\" />"
+
+ *David Celis*
+
+* Element of the `collection_check_boxes` and `collection_radio_buttons` can
+ optionally contain html attributes as the last element of the array.
+
+ *Vasiliy Ermolovich*
+
+* Update the HTML `BOOLEAN_ATTRIBUTES` in `ActionView::Helpers::TagHelper`
+ to conform to the latest HTML 5.1 spec. Add attributes `allowfullscreen`,
+ `default`, `inert`, `sortable`, `truespeed`, `typemustmatch`. Fix attribute
+ `seamless` (previously misspelled `seemless`).
+
+ *Alex Peattie*
+
* Fix an issue where partials with a number in the filename weren't being digested for cache dependencies.
*Bryan Ricker*
diff --git a/actionpack/lib/action_dispatch/middleware/cookies.rb b/actionpack/lib/action_dispatch/middleware/cookies.rb
index 5b914f293d..d055acb296 100644
--- a/actionpack/lib/action_dispatch/middleware/cookies.rb
+++ b/actionpack/lib/action_dispatch/middleware/cookies.rb
@@ -77,7 +77,7 @@ module ActionDispatch
# domain and subdomains.
#
# * <tt>:expires</tt> - The time at which this cookie expires, as a \Time object.
- # * <tt>:secure</tt> - Whether this cookie is a only transmitted to HTTPS servers.
+ # * <tt>:secure</tt> - Whether this cookie is only transmitted to HTTPS servers.
# Default is +false+.
# * <tt>:httponly</tt> - Whether this cookie is accessible via scripting or
# only HTTP. Defaults to +false+.
diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb
index edf37bb9a5..2dfaab3587 100644
--- a/actionpack/lib/action_dispatch/railtie.rb
+++ b/actionpack/lib/action_dispatch/railtie.rb
@@ -20,8 +20,7 @@ module ActionDispatch
config.action_dispatch.default_headers = {
'X-Frame-Options' => 'SAMEORIGIN',
'X-XSS-Protection' => '1; mode=block',
- 'X-Content-Type-Options' => 'nosniff',
- 'X-UA-Compatible' => 'chrome=1'
+ 'X-Content-Type-Options' => 'nosniff'
}
config.eager_load_namespaces << ActionDispatch
diff --git a/actionpack/lib/action_view/helpers/asset_url_helper.rb b/actionpack/lib/action_view/helpers/asset_url_helper.rb
index b5f2df76ab..0b957adb91 100644
--- a/actionpack/lib/action_view/helpers/asset_url_helper.rb
+++ b/actionpack/lib/action_view/helpers/asset_url_helper.rb
@@ -105,7 +105,7 @@ module ActionView
# )
#
module AssetUrlHelper
- URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}
+ URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}i
# Computes the path to asset in public directory. If :type
# options is set, a file extension will be appended and scoped
diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb
index 3939e4737b..732f35643a 100644
--- a/actionpack/lib/action_view/helpers/tag_helper.rb
+++ b/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -12,8 +12,11 @@ module ActionView
BOOLEAN_ATTRIBUTES = %w(disabled readonly multiple checked autobuffer
autoplay controls loop selected hidden scoped async
- defer reversed ismap seemless muted required
- autofocus novalidate formnovalidate open pubdate itemscope).to_set
+ defer reversed ismap seamless muted required
+ autofocus novalidate formnovalidate open pubdate
+ itemscope allowfullscreen default inert sortable
+ truespeed typemustmatch).to_set
+
BOOLEAN_ATTRIBUTES.merge(BOOLEAN_ATTRIBUTES.map {|attribute| attribute.to_sym })
PRE_CONTENT_STRINGS = {
diff --git a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb
index cd12ddaf65..388dcf1f13 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_helpers.rb
+++ b/actionpack/lib/action_view/helpers/tags/collection_helpers.rb
@@ -73,8 +73,9 @@ module ActionView
value = value_for_collection(item, @value_method)
text = value_for_collection(item, @text_method)
default_html_options = default_html_options_for_collection(item, value)
+ additional_html_options = option_html_attributes(item)
- yield item, value, text, default_html_options
+ yield item, value, text, default_html_options.merge(additional_html_options)
end.join.html_safe
end
end
diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb
index 8a83f6f356..19e5941971 100644
--- a/actionpack/lib/action_view/helpers/url_helper.rb
+++ b/actionpack/lib/action_view/helpers/url_helper.rb
@@ -380,7 +380,7 @@ module ActionView
if block_given?
block.arity <= 1 ? capture(name, &block) : capture(name, options, html_options, &block)
else
- name
+ ERB::Util.html_escape(name)
end
else
link_to(name, options, html_options)
diff --git a/actionpack/lib/action_view/template.rb b/actionpack/lib/action_view/template.rb
index c25b1efc2b..e2c50fec47 100644
--- a/actionpack/lib/action_view/template.rb
+++ b/actionpack/lib/action_view/template.rb
@@ -267,7 +267,7 @@ module ActionView
method_name = self.method_name
code = @handler.call(self)
- # Make sure that the resulting String to be evalled is in the
+ # Make sure that the resulting String to be eval'd is in the
# encoding of the code
source = <<-end_src
def #{method_name}(local_assigns, output_buffer)
diff --git a/actionpack/test/dispatch/response_test.rb b/actionpack/test/dispatch/response_test.rb
index 74f5253c11..2fbe7358f9 100644
--- a/actionpack/test/dispatch/response_test.rb
+++ b/actionpack/test/dispatch/response_test.rb
@@ -182,8 +182,7 @@ class ResponseTest < ActiveSupport::TestCase
ActionDispatch::Response.default_headers = {
'X-Frame-Options' => 'DENY',
'X-Content-Type-Options' => 'nosniff',
- 'X-XSS-Protection' => '1;',
- 'X-UA-Compatible' => 'chrome=1'
+ 'X-XSS-Protection' => '1;'
}
resp = ActionDispatch::Response.new.tap { |response|
response.body = 'Hello'
@@ -193,7 +192,6 @@ class ResponseTest < ActiveSupport::TestCase
assert_equal('DENY', resp.headers['X-Frame-Options'])
assert_equal('nosniff', resp.headers['X-Content-Type-Options'])
assert_equal('1;', resp.headers['X-XSS-Protection'])
- assert_equal('chrome=1', resp.headers['X-UA-Compatible'])
ensure
ActionDispatch::Response.default_headers = nil
end
diff --git a/actionpack/test/template/asset_tag_helper_test.rb b/actionpack/test/template/asset_tag_helper_test.rb
index 8d0ab7fd81..214a13654e 100644
--- a/actionpack/test/template/asset_tag_helper_test.rb
+++ b/actionpack/test/template/asset_tag_helper_test.rb
@@ -48,6 +48,9 @@ class AssetTagHelperTest < ActionView::TestCase
%(asset_path("style.min")) => %(/style.min),
%(asset_path("style.min.css")) => %(/style.min.css),
+ %(asset_path("http://www.outside.com/image.jpg")) => %(http://www.outside.com/image.jpg),
+ %(asset_path("HTTP://www.outside.com/image.jpg")) => %(HTTP://www.outside.com/image.jpg),
+
%(asset_path("style", type: :stylesheet)) => %(/stylesheets/style.css),
%(asset_path("xmlhr", type: :javascript)) => %(/javascripts/xmlhr.js),
%(asset_path("xml.png", type: :image)) => %(/images/xml.png)
@@ -445,8 +448,8 @@ class AssetTagHelperTest < ActionView::TestCase
[nil, '/', '/foo/bar/', 'foo/bar/'].each do |prefix|
assert_equal 'Rails', image_alt("#{prefix}rails.png")
assert_equal 'Rails', image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
- assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
- assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
+ assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
+ assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
end
end
diff --git a/actionpack/test/template/dependency_tracker_test.rb b/actionpack/test/template/dependency_tracker_test.rb
index 8588925de3..7a9b4b26ac 100644
--- a/actionpack/test/template/dependency_tracker_test.rb
+++ b/actionpack/test/template/dependency_tracker_test.rb
@@ -45,7 +45,7 @@ class DependencyTrackerTest < ActionView::TestCase
end
end
-class ERBTrackerTest < MiniTest::Unit::TestCase
+class ERBTrackerTest < Minitest::Test
def make_tracker(name, template)
ActionView::DependencyTracker::ERBTracker.new(name, template)
end
diff --git a/actionpack/test/template/form_collections_helper_test.rb b/actionpack/test/template/form_collections_helper_test.rb
index 2131f81396..bc9c21dfd3 100644
--- a/actionpack/test/template/form_collections_helper_test.rb
+++ b/actionpack/test/template/form_collections_helper_test.rb
@@ -76,6 +76,14 @@ class FormCollectionsHelperTest < ActionView::TestCase
assert_select 'input[type=radio][value=false].special-radio#user_active_false'
end
+ test 'collection radio accepts html options as the last element of array' do
+ collection = [[1, true, {class: 'foo'}], [0, false, {class: 'bar'}]]
+ with_collection_radio_buttons :user, :active, collection, :second, :first
+
+ assert_select 'input[type=radio][value=true].foo#user_active_true'
+ assert_select 'input[type=radio][value=false].bar#user_active_false'
+ end
+
test 'collection radio does not wrap input inside the label' do
with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s
@@ -192,6 +200,14 @@ class FormCollectionsHelperTest < ActionView::TestCase
assert_select 'label[for=user_name_199]', '$1.99'
end
+ test 'collection check boxes accepts html options as the last element of array' do
+ collection = [[1, 'Category 1', {class: 'foo'}], [2, 'Category 2', {class: 'bar'}]]
+ with_collection_check_boxes :user, :active, collection, :first, :second
+
+ assert_select 'input[type=checkbox][value=1].foo'
+ assert_select 'input[type=checkbox][value=2].bar'
+ end
+
test 'collection check boxes accepts selected values as :checked option' do
collection = (1..3).map{|i| [i, "Category #{i}"] }
with_collection_check_boxes :user, :category_ids, collection, :first, :last, :checked => [1, 3]
diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb
index 9e711c6529..802da5d566 100644
--- a/actionpack/test/template/tag_helper_test.rb
+++ b/actionpack/test/template/tag_helper_test.rb
@@ -30,8 +30,8 @@ class TagHelperTest < ActionView::TestCase
end
def test_tag_options_converts_boolean_option
- assert_equal '<p disabled="disabled" itemscope="itemscope" multiple="multiple" readonly="readonly" />',
- tag("p", :disabled => true, :itemscope => true, :multiple => true, :readonly => true)
+ assert_dom_equal '<p disabled="disabled" itemscope="itemscope" multiple="multiple" readonly="readonly" allowfullscreen="allowfullscreen" seamless="seamless" typemustmatch="typemustmatch" sortable="sortable" default="default" inert="inert" truespeed="truespeed" />',
+ tag("p", :disabled => true, :itemscope => true, :multiple => true, :readonly => true, :allowfullscreen => true, :seamless => true, :typemustmatch => true, :sortable => true, :default => true, :inert => true, :truespeed => true)
end
def test_content_tag
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index f63f235a5c..eb4349015a 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -348,6 +348,11 @@ class UrlHelperTest < ActiveSupport::TestCase
link_to_unless(true, "Showing", url_hash) {
"test"
}
+
+ assert_equal %{&lt;b&gt;Showing&lt;/b&gt;}, link_to_unless(true, "<b>Showing</b>", url_hash)
+ assert_equal %{<a href="/">&lt;b&gt;Showing&lt;/b&gt;</a>}, link_to_unless(false, "<b>Showing</b>", url_hash)
+ assert_equal %{<b>Showing</b>}, link_to_unless(true, "<b>Showing</b>".html_safe, url_hash)
+ assert_equal %{<a href="/"><b>Showing</b></a>}, link_to_unless(false, "<b>Showing</b>".html_safe, url_hash)
end
def test_link_to_if