bh 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f5835cd462fb3d11c1aed1d680b9cad2e07118a
4
- data.tar.gz: a790bdc43c1d08155d6768fb871c4c1317dfd3f8
3
+ metadata.gz: 990dc7edcfb65b8cf34d156eec8abc3f18e32c9f
4
+ data.tar.gz: 9ad5be9c224508ed6cd2f43406561e36ed6eb688
5
5
  SHA512:
6
- metadata.gz: ccf655fafab88fbb6b66c7e5b65fca87bcec689a4e23f3d75b934555146d703e3b01509491b8d348cb4f1a113491e7f4c572eafbedd62a01669e639543c94b0d
7
- data.tar.gz: 9286a9d3ae256ba18927d8c5f2b9dfcfa29b2ef2455c83f00cd65e8f052481a36322fc8129181e5496147ba52b0722389f146201eb48bddb3abbf2c48fd84d35
6
+ metadata.gz: b31c41c110c0f70965c0a5172d6c1bc6f7c84f652da0c8335a434e6d6b6f75d567464e60c87b04a4e0001f8454c5cf1085669bae83069cbb400cb2975155ca72
7
+ data.tar.gz: cf475af91cb93ffb13a82177c35dd33415c021fd264928ce4b8e9973654efab0e77dcc9128d385a253613083274b8485bdef66745e152bd1d84e913d2b89ecbb
@@ -6,6 +6,18 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 1.3.4 - 2014-06-23
10
+
11
+ * [BUGFIX] Security: don’t always assume that the content of `link_to` is safe
12
+
13
+ Note that this might break your code if it relied on the wrong behavior of
14
+ Bh, assuming that the content of `link_to` was always HTML safe.
15
+
16
+ For instance, if your app has the following code to display an image with a
17
+ link `link_to '<img src="logo.png">', '/'`, then the image will not display
18
+ anymore, since Bh now correctly escapes the HTML content (as Rails and Padrino
19
+ do). In this case, you should use `link_to image_tag('logo.png'), '/'` instead.
20
+
9
21
  ## 1.3.3 - 2014-03-11
10
22
 
11
23
  * [BUGFIX] Correctly align the "X" icon at the right of the field in basic forms
data/README.md CHANGED
@@ -44,7 +44,7 @@ The other ones are: `bootstrap_css`, `bootstrap_js`, `bootstrap_theme_css`,
44
44
  How to install
45
45
  ==============
46
46
 
47
- Bh is compatible with **Rails 3**, **Rails 4**, **Padrino** and **Middleman**.
47
+ Bh is compatible with **Rails 3.2**, **Rails 4**, **Padrino** and **Middleman**.
48
48
 
49
49
  To include the Bh gem in your project:
50
50
 
@@ -1,8 +1,8 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'activesupport', '~> 3.0'
4
- gem 'actionpack', '~> 3.0'
5
- gem 'activemodel', '~> 3.0'
3
+ gem 'activesupport', '~> 3.2'
4
+ gem 'actionpack', '~> 3.2'
5
+ gem 'activemodel', '~> 3.2'
6
6
  gem 'middleman-core', '~> 3.2.2'
7
7
 
8
8
  gemspec path: '../'
@@ -59,7 +59,7 @@ module Bh
59
59
  items = Array.wrap(@content).map do |item|
60
60
  item.is_a?(Base) ? item.content_tag(item.tag) : item
61
61
  end
62
- safe_join items
62
+ items.all?(&:html_safe?) ? safe_join(items) : items.join
63
63
  end
64
64
 
65
65
  def content_tag(tag)
@@ -1,3 +1,3 @@
1
1
  module Bh
2
- VERSION = '1.3.3'
2
+ VERSION = '1.3.4'
3
3
  end
@@ -5,6 +5,8 @@ shared_examples_for 'the link_to helper' do
5
5
  all_tests_pass_with 'the link wrapped in dropdown'
6
6
  all_tests_pass_with 'the link wrapped in nav'
7
7
  all_tests_pass_with 'the link wrapped in vertical'
8
+ all_tests_pass_with 'the link including unsafe Javascript'
9
+ all_tests_pass_with 'the link including safe HTML content'
8
10
  end
9
11
 
10
12
  #--
@@ -55,8 +57,28 @@ shared_examples_for 'the link wrapped in nav' do
55
57
  end
56
58
 
57
59
  shared_examples_for 'the link wrapped in vertical' do
58
- specify 'surrounds the link in a <li> item' do
59
- html = '<li><a href="/">content</a></li>'
60
- bh.vertical { expect(:link_to).to generate html }
60
+ specify 'adds the "navbar-brand" class to the link' do
61
+ html = %r{^<a.+class="navbar-brand".*>content</a>$}
62
+ bh.navbar(id: 'id') do
63
+ bh.vertical { expect(:link_to).to generate html }
64
+ end
61
65
  end
62
- end
66
+ end
67
+
68
+ shared_examples_for 'the link including unsafe Javascript' do
69
+ specify 'uses the original link_to helper which escapes the link' do
70
+ expect(link_to: :xss_script).not_to generate %r{<script>}
71
+ bh.alert_box { expect(link_to: :xss_script).not_to generate %r{<script>} }
72
+ bh.dropdown('') { expect(link_to: :xss_script).not_to generate %r{<script>} }
73
+ bh.nav { expect(link_to: :xss_script).not_to generate %r{<script>} }
74
+ bh.navbar(id: 'id') do
75
+ bh.vertical { expect(link_to: :xss_script).not_to generate %r{<script>} }
76
+ end
77
+ end
78
+ end
79
+
80
+ shared_examples_for 'the link including safe HTML content' do
81
+ specify 'does not escape the HTML content' do
82
+ expect(link_to: :safe_html).to generate %r{<hr />}
83
+ end
84
+ end
@@ -7,6 +7,12 @@ RSpec::Matchers.define :generate do |html|
7
7
  if helper == :link_to && options == :nil_name
8
8
  @inline = bh.send helper, nil, '/'
9
9
  @block = @inline
10
+ elsif helper == :link_to && options == :xss_script
11
+ @inline = bh.send helper, '<script>alert("xss")</script>', '/'
12
+ @block = bh.send(helper, '/') { '<script>alert("xss")</script>' }
13
+ elsif helper == :link_to && options == :safe_html
14
+ @inline = bh.send helper, bh.tag(:hr), '/'
15
+ @block = bh.send(helper, '/') { bh.tag(:hr) }
10
16
  elsif helper == :link_to || helper == :button_to
11
17
  @inline = bh.send helper, *['content', '/', options].compact
12
18
  if bh.test_button_to_with_block
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.3
4
+ version: 1.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-11 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport