escape_utils 1.0.0 → 1.0.1

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: 7e59c356d88fb33a0a31f0668c2e476d45bcced9
4
- data.tar.gz: a8df94fbbc6f8aed27e5c59d53678f944ef782da
3
+ metadata.gz: a15665f9653635141dfb582e5748299d6f31359f
4
+ data.tar.gz: 8ed831486f3292a3dd31f20e2b460218bf50cfe5
5
5
  SHA512:
6
- metadata.gz: 980b6eef8962eac5f49e61154e1a26018c4e6a1be57a3d3c7aaa5acab8dac52076750edab093d3b0ed8ea47a00d7d222520251ed5f9a8bf6885d2e26e39d034e
7
- data.tar.gz: 09ccd6442abd623df06036d418833af4d3bd1b63ee74f582f08f0537dccc7f29405ed934b7d2c0edbdab0d1c956a44946b2e8709f62ba1a214f28f814bdd1a28
6
+ metadata.gz: 587f6c30123a5478c3d1775b305cca518342e1d7b1ed0e882a6aeb225e1858812e4d0107b5b00ae8bd3f78a27ecf729217a02660ae58a099d044b634a64d05ec
7
+ data.tar.gz: 1dc21ebae6acdef6bacea70b303ed8fc251c5ba479b729ad2bb2670396a9a423342fe136fc255d7fe4f8bb808ef4fa4baebb8962db9abd5f5323bd585372bdfa
@@ -7,14 +7,16 @@ Gem::Specification.new do |s|
7
7
  s.email = %q{seniorlopez@gmail.com}
8
8
  s.extensions = ["ext/escape_utils/extconf.rb"]
9
9
  s.files = `git ls-files`.split("\n")
10
- s.homepage = %q{http://github.com/brianmario/escape_utils}
10
+ s.homepage = %q{https://github.com/brianmario/escape_utils}
11
+ s.license = %q{MIT}
11
12
  s.rdoc_options = ["--charset=UTF-8"]
12
13
  s.require_paths = ["lib"]
13
14
  s.rubygems_version = %q{1.4.2}
14
15
  s.summary = %q{Faster string escaping routines for your web apps}
16
+ s.description = %q{Quickly perform HTML, URL, URI and Javascript escaping/unescaping}
15
17
  s.test_files = `git ls-files test`.split("\n")
16
18
 
17
- s.required_ruby_version = "> 1.9.3"
19
+ s.required_ruby_version = ">= 1.9.3"
18
20
 
19
21
  # tests
20
22
  s.add_development_dependency 'rake-compiler', ">= 0.7.5"
@@ -96,6 +96,11 @@ rb_eu__generic(VALUE str, houdini_cb do_escape)
96
96
  /**
97
97
  * HTML methods
98
98
  */
99
+ static VALUE new_html_safe_string(const char *ptr, size_t len)
100
+ {
101
+ return rb_str_new_with_class(rb_html_safe_string_template_object, ptr, len);
102
+ }
103
+
99
104
  static VALUE rb_eu_escape_html_as_html_safe(VALUE self, VALUE str)
100
105
  {
101
106
  VALUE result;
@@ -106,11 +111,10 @@ static VALUE rb_eu_escape_html_as_html_safe(VALUE self, VALUE str)
106
111
  check_utf8_encoding(str);
107
112
 
108
113
  if (houdini_escape_html0(&buf, (const uint8_t *)RSTRING_PTR(str), RSTRING_LEN(str), secure)) {
109
- result = eu_new_str(buf.ptr, buf.size);
114
+ result = new_html_safe_string(buf.ptr, buf.size);
110
115
  gh_buf_free(&buf);
111
116
  } else {
112
- result = rb_str_new_with_class(rb_html_safe_string_template_object,
113
- RSTRING_PTR(str), RSTRING_LEN(str));
117
+ result = new_html_safe_string(RSTRING_PTR(str), RSTRING_LEN(str));
114
118
  }
115
119
 
116
120
  rb_ivar_set(result, ID_at_html_safe, Qtrue);
@@ -1,3 +1,3 @@
1
1
  module EscapeUtils
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -56,6 +56,18 @@ class HtmlEscapeTest < Minitest::Test
56
56
  EscapeUtils.html_safe_string_class = klass_before
57
57
  end
58
58
 
59
+ def test_returns_custom_string_class_when_string_requires_escaping
60
+ klass_before = EscapeUtils.html_safe_string_class
61
+ EscapeUtils.html_safe_string_class = MyCustomHtmlSafeString
62
+
63
+ str = EscapeUtils.escape_html_as_html_safe("<script>")
64
+ assert_equal "&lt;script&gt;", str
65
+ assert_equal MyCustomHtmlSafeString, str.class
66
+ assert_equal true, str.instance_variable_get(:@html_safe)
67
+ ensure
68
+ EscapeUtils.html_safe_string_class = klass_before
69
+ end
70
+
59
71
  def test_html_safe_string_class_descends_string
60
72
  assert_raises ArgumentError do
61
73
  EscapeUtils.html_safe_string_class = Hash
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escape_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Lopez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-29 00:00:00.000000000 Z
11
+ date: 2014-01-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -108,7 +108,7 @@ dependencies:
108
108
  - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
- description:
111
+ description: Quickly perform HTML, URL, URI and Javascript escaping/unescaping
112
112
  email: seniorlopez@gmail.com
113
113
  executables: []
114
114
  extensions:
@@ -117,7 +117,6 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
119
  - .travis.yml
120
- - CHANGELOG.md
121
120
  - Gemfile
122
121
  - MIT-LICENSE
123
122
  - README.md
@@ -171,8 +170,9 @@ files:
171
170
  - test/url/escape_test.rb
172
171
  - test/url/unescape_test.rb
173
172
  - test/xml/escape_test.rb
174
- homepage: http://github.com/brianmario/escape_utils
175
- licenses: []
173
+ homepage: https://github.com/brianmario/escape_utils
174
+ licenses:
175
+ - MIT
176
176
  metadata: {}
177
177
  post_install_message:
178
178
  rdoc_options:
@@ -181,7 +181,7 @@ require_paths:
181
181
  - lib
182
182
  required_ruby_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - '>'
184
+ - - '>='
185
185
  - !ruby/object:Gem::Version
186
186
  version: 1.9.3
187
187
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -1,75 +0,0 @@
1
- # Changelog
2
-
3
- ## 0.3.2 (February 28th, 2013)
4
- * fix rbx compatibility
5
- * add EscapeUtils.html_safe_string_class
6
- * add EscapeUtils.escape_html_as_html_safe
7
-
8
- ## 0.3.1 (February 26th, 2013)
9
- * fixed compilation on Windows
10
-
11
- ## 0.3.0 (February 26th, 2013)
12
- * add xml escaping support
13
- * in Ruby 1.9 - escape_utils now requires the input string be UTF-8
14
- * update upstream houdini to pull in some speed optimizations
15
- * a couple of other perf tweaks
16
- * switched to minitest
17
-
18
- ## 0.2.4 (September 7th, 2011)
19
- * swap out custom escaping routines for houdini - https://github.com/tanoku/houdini
20
- * add RSTRING_NOT_MODIFIED define for a Rubinius speedup
21
-
22
- ## 0.2.3 (March 9th, 2011)
23
- * change encoding strategy to simply return strings in the encoding the input string was in, not taking into account Encoding.default_internal
24
-
25
- ## 0.2.2 (February 25th, 2011)
26
- * minor fix for Rubinius compatibility
27
-
28
- ## 0.2.1 (February 21st, 2011)
29
- * fix buffer over read in unescape_url and unescape_uri
30
-
31
- ## 0.2.0 (February 8th, 2011)
32
- * fixed a couple of compilation warnings on 1.9.3
33
- * moved to rspec2
34
- * remove hard-conversion to utf-8 to preserve the string's original encoding
35
- * moved to rake-compiler, Bundler
36
- * pass through incompletely escaped data on unescaping
37
- * added tilde to escape_{uri,url}specs (It's a difference between CGI.escape and URI.escape)
38
- * escape_uri and escape_url now match their Ruby counterparts
39
- ** escape_uri is used where URI.escape is, and escape_url is used where CGI.escape is used.
40
- * performance and memory usage optimizations
41
-
42
- ## 0.1.9 (October 15th, 2010)
43
- * add a flag as an optional 2nd parameter to EscapeUtils.escape_html to disable/enable the escaping of the '/' character. Defaults to the new flag EscapeUtils.html_secure
44
-
45
- ## 0.1.8 (September 29th, 2010)
46
- * fix URI escaping one last time ;)
47
-
48
- ## 0.1.7 (September 29th, 2010)
49
- * fix URI escaping to act according to the RFC
50
- * add specs for URL escaping
51
-
52
- ## 0.1.6 (September 6th, 2010)
53
- * support for URI escaping added (thanks to @joshbuddy)
54
- * bugfix to ensure we don't drop opening tags during escape_javascript (thanks to @nagybence)
55
-
56
- ## 0.1.5 (July 13th, 2010)
57
- * add URL escaping and unescaping
58
- * major refactor of HTML and Javascript escaping and unescaping logic for a decent speed up
59
- * HTML escaping now takes html_safe? into account (for Rails/ActiveSupport users) - thanks yury!
60
-
61
- ## 0.1.4 (June 9th, 2010)
62
- * ensure strings are passed in from monkey-patches
63
-
64
- ## 0.1.3 (June 9th, 2010)
65
- * cleaned some code up, removing duplication
66
- * moved to a more flexible character encoding scheme using Encoding.defaut_internal for 1.9 users
67
-
68
- ## 0.1.2 (June 8th, 2010)
69
- * forgot to add the ActionView monkey patch for JS escaping ;)
70
-
71
- ## 0.1.1 (June 8th, 2010)
72
- * added javascript escaping
73
-
74
- ## 0.1.0 (June 8th, 2010)
75
- * initial release