string_master 0.3.18 → 0.3.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/string_master/string_master.rb +4 -2
- data/spec/lib/string_master/string_master_spec.rb +16 -1
- data/string_master.gemspec +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5a075abc613363e9a4ff6a34fb2e090f904ad2e
|
4
|
+
data.tar.gz: cf180f4ff24e411cb4dc101be650c85de93fa3f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f94f5a00b02b0a9f2e5652816f69406ab1fc61c27f8ffc769299cc12827e6a30993f2c5fb9b88d3b991c8e4df9ef1c08b0c0ca788b51edbcde0f1763a56f4fe
|
7
|
+
data.tar.gz: ca02e659e224132ba171ac05fee58d0f4f97276e5236c03c1abf0062ee1a05dd33d9fce2567471724173e8af6fce210682c1e19227ec81f3f47c45e196b876ad
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.19
|
@@ -33,7 +33,7 @@ class StringMaster
|
|
33
33
|
def html_escape(options={})
|
34
34
|
except = options[:except] || %w()
|
35
35
|
close_tags
|
36
|
-
@modified_string.gsub!(/<\/?(
|
36
|
+
@modified_string.gsub!(/<\/?(.*?)(\s.*?)?\/?>/) do |tag|
|
37
37
|
if except.include?($1)
|
38
38
|
# sanitize attributes
|
39
39
|
tag.gsub(/\s(.+?)=('|").*?\2(?=.*?>)/) do |a|
|
@@ -44,7 +44,9 @@ class StringMaster
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
# Convert all unclosed left tag brackets (<) into <
|
47
|
-
@modified_string.gsub!(
|
47
|
+
@modified_string.gsub!(/<+([^>]*)\Z/, '<\1')
|
48
|
+
# Convert all unopened right tag brackets (<) into <
|
49
|
+
@modified_string.gsub!(/\A([^<]*)>+/, '\1>')
|
48
50
|
self
|
49
51
|
end
|
50
52
|
|
@@ -27,7 +27,22 @@ describe StringMaster do
|
|
27
27
|
parser.html_escape.to_s.should == 'xsstest<input/onfocus=prompt(document.cookie)autofocus>'
|
28
28
|
|
29
29
|
parser = StringMaster.new('xsstest"><input/onfocus=prompt() autofocus /=')
|
30
|
-
parser.html_escape.to_s.should == 'xsstest"
|
30
|
+
parser.html_escape.to_s.should == 'xsstest"><input/onfocus=prompt() autofocus /='
|
31
|
+
|
32
|
+
parser = StringMaster.new('xsstest"><input/onfocus=prompt() autofocus /= <img>')
|
33
|
+
parser.html_escape.to_s.should == 'xsstest"><input/onfocus=prompt() autofocus /= <img>'
|
34
|
+
|
35
|
+
parser = StringMaster.new('xsstest"><input/onfocus=prompt() autofocus /= <img>')
|
36
|
+
parser.html_escape(except: %w(img)).to_s.should == 'xsstest"><input/onfocus=prompt() autofocus /= <img>'
|
37
|
+
|
38
|
+
parser = StringMaster.new('aaaa"<input/autofocus/onfocus=prompt(\'textxss\')//<>>')
|
39
|
+
parser.html_escape(except: %w(img)).to_s.should == 'aaaa"<input/autofocus/onfocus=prompt('textxss')//<>>'
|
40
|
+
|
41
|
+
parser = StringMaster.new('aaaa"<<<<<input/autofocus/onfocus=prompt(\'textxss\')//<<<<>>>>>')
|
42
|
+
parser.html_escape(except: %w(img)).to_s.should == 'aaaa"<<<<<input/autofocus/onfocus=prompt('textxss')//<<<<>>>>>'
|
43
|
+
|
44
|
+
parser = StringMaster.new('aaaa"<input<<<<input/autofocus/onfocus=prompt(\'textxss\')//<<<<hello>>>>>')
|
45
|
+
parser.html_escape(except: %w(img)).to_s.should == 'aaaa"<input<<<<input/autofocus/onfocus=prompt('textxss')//<<<<hello>>>>></hello>'
|
31
46
|
|
32
47
|
parser = StringMaster.new('<img onload="do_something()">')
|
33
48
|
parser.html_escape(except: %w(img)).to_s.should == '<img>'
|
data/string_master.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: string_master 0.3.
|
5
|
+
# stub: string_master 0.3.19 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "string_master"
|
9
|
-
s.version = "0.3.
|
9
|
+
s.version = "0.3.19"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|