breadcrumbs 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -29,6 +29,8 @@ class Breadcrumbs
29
29
  options[:class] << " #{css.join(" ")}"
30
30
  options[:class].gsub!(/^ *(.*?)$/, '\\1')
31
31
 
32
+ text = CGI.escapeHTML(text)
33
+
32
34
  if url
33
35
  text = tag(:a, text, options.merge(:href => url))
34
36
  else
@@ -24,7 +24,7 @@ class Breadcrumbs
24
24
  css << "item-#{i}"
25
25
 
26
26
  text, url, options = *item
27
-
27
+ text = CGI.escapeHTML(text)
28
28
  text = tag(:a, text, options.merge(:href => url)) if url
29
29
 
30
30
  tag(:li, text, :class => css.join(" "))
@@ -2,7 +2,7 @@ class Breadcrumbs
2
2
  module Version # :nodoc: all
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 0
5
+ PATCH = 1
6
6
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
7
  end
8
8
  end
data/lib/breadcrumbs.rb CHANGED
@@ -44,7 +44,7 @@ class Breadcrumbs
44
44
 
45
45
  def translate(scope) # :nodoc:
46
46
  text = I18n.t(scope, :scope => :breadcrumbs, :raise => true) rescue nil
47
- text ||= I18n.t(scope, :default => scope)
47
+ text ||= I18n.t(scope, :default => scope.to_s)
48
48
  text
49
49
  end
50
50
  end
@@ -145,8 +145,34 @@ class BreadcrumbsTest < Test::Unit::TestCase
145
145
  assert_equal "Nosso time", items[1].inner_text
146
146
  end
147
147
 
148
+ def test_render_scope_as_text_for_missing_scope
149
+ @breadcrumbs.add :contact
150
+ @breadcrumbs.add "Help"
151
+
152
+ html = Nokogiri::HTML(@breadcrumbs.render)
153
+
154
+ items = html.search("li")
155
+
156
+ assert_equal "contact", items[0].inner_text
157
+ assert_equal "Help", items[1].inner_text
158
+ end
159
+
148
160
  def test_pimp_action_controller
149
161
  methods = ActionController::Base.instance_methods
150
162
  assert (methods.include?(:breadcrumbs) || methods.include?("breadcrumbs"))
151
163
  end
164
+
165
+ def test_escape_text_when_rendering_inline
166
+ @breadcrumbs.add "<script>alert(1)</script>"
167
+ html = @breadcrumbs.render(:format => :inline)
168
+
169
+ assert_equal %[<span class="first last item-0">&lt;script&gt;alert(1)&lt;/script&gt;</span>], html
170
+ end
171
+
172
+ def test_escape_text_when_rendering_list
173
+ @breadcrumbs.add "<script>alert(1)</script>"
174
+ html = @breadcrumbs.render
175
+
176
+ assert_match /&lt;script&gt;alert\(1\)&lt;\/script&gt;/, html
177
+ end
152
178
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Nando Vieira
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-24 00:00:00 -03:00
17
+ date: 2010-03-25 00:00:00 -03:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ files:
50
50
  - test/resources/pt.yml
51
51
  - test/test_helper.rb
52
52
  has_rdoc: true
53
- homepage: http://github.com/fnando/games_radar
53
+ homepage: http://github.com/fnando/breadcrumbs
54
54
  licenses: []
55
55
 
56
56
  post_install_message: