easy_dl 0.0.3 → 0.0.4

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.
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ source 'https://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'railties', '~> 3.2.0'
7
- #gem 'activemodel', '~> 3.2.0'
8
7
  gem 'actionpack', '~> 3.2.0'
9
8
 
10
9
  gem 'mocha'
@@ -19,7 +19,7 @@ module EasyDl
19
19
  yield @obj
20
20
  else
21
21
  if val = @obj.send(name)
22
- concat(val.to_s)
22
+ concat @template.html_escape( @obj.send(name) )
23
23
  end
24
24
  end
25
25
  concat '</dd>'
@@ -1,3 +1,3 @@
1
1
  module EasyDl
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require File.expand_path("../test_helper", __FILE__)
2
2
 
3
3
  class DlHelperTest < ActionView::TestCase
4
4
 
@@ -39,4 +39,18 @@ class DlHelperTest < ActionView::TestCase
39
39
  end
40
40
  end
41
41
 
42
+ context 'malicious definition list' do
43
+ setup do
44
+ @person = OpenStruct.new(name: '<script>alert("John")</alert>', surname: '<script>alert("Doe")</alert>')
45
+ concat(definition_list_for(@person, class: 'easy2') do |d|
46
+ d.item :name
47
+ d.item :surname
48
+ end)
49
+ end
50
+
51
+ should 'escape html tags' do
52
+ assert_select '.easy2 dd', "&lt;script&gt;alert(&quot;John&quot;)&lt;/alert&gt;"
53
+ end
54
+ end
55
+
42
56
  end
data/test/test_helper.rb CHANGED
@@ -26,4 +26,8 @@ I18n.default_locale = :en
26
26
  class ActionView::TestCase
27
27
  include EasyDl::DlHelper
28
28
 
29
+ def html_escape(value)
30
+ value.to_s.gsub(/[&<>"]/) { |s| {'&' => '&amp;', '<' => '&lt;', '>' => '&gt;', '"' => '&quot;', "'" => '&#039;', }[s] }
31
+ end
32
+
29
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_dl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-05 00:00:00.000000000 Z
12
+ date: 2012-12-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Gem for generating html definition lists in Rails 3
15
15
  email: