escape_utils 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2 (June 8th, 2010)
4
+ * forgot to add the ActionView monkey patch for JS escaping ;)
5
+
3
6
  ## 0.1.1 (June 8th, 2010)
4
7
  * added javascript escaping
5
8
 
@@ -4,7 +4,7 @@ Being as though we're all html escaping everything these days, why not make it f
4
4
 
5
5
  At the moment escape_utils supports escaping and unescaping of HTML, and Javascript but I wanna add URL encoding soon
6
6
 
7
- It has monkey-patches for Rack::Utils, CGI, ERB::Util and Haml
7
+ It has monkey-patches for Rack::Utils, CGI, ERB::Util and Haml and ActionView so you can drop this in and have your app start escaping fast as balls in no time
8
8
 
9
9
  == Installing
10
10
 
@@ -12,28 +12,36 @@ It has monkey-patches for Rack::Utils, CGI, ERB::Util and Haml
12
12
 
13
13
  == Usage
14
14
 
15
- === Escaping HTML
15
+ === HTML
16
+
17
+ ==== Escaping
16
18
 
17
19
  html = `curl -s http://maps.google.com`
18
20
  escaped_html = EscapeUtils.escape_html(html)
19
21
 
20
- === Unescaping HTML
22
+ ==== Unescaping
21
23
 
22
24
  html = `curl -s http://maps.google.com`
23
25
  escaped_html = EscapeUtils.escape_html(html)
24
26
  html = EscapeUtils.unescape_html(escaped_html)
25
27
 
26
- === Escaping Javascript
28
+ ==== Monkey Patches
29
+
30
+ require 'escape_utils/html/rack' # to patch Rack::Utils
31
+ require 'escape_utils/html/erb' # to patch ERB::Util
32
+ require 'escape_utils/html/cgi' # to patch CGI
33
+ require 'escape_utils/html/haml' # to patch Haml::Helpers
34
+
35
+ === Javascript
36
+
37
+ ==== Escaping
27
38
 
28
39
  javascript = `curl -s http://code.jquery.com/jquery-1.4.2.js`
29
40
  escaped_javascript = EscapeUtils.escape_javascript(javascript)
30
41
 
31
- === Monkey Patches
42
+ ==== Monkey Patches
32
43
 
33
- require 'escape_utils/rack' # to patch Rack::Utils
34
- require 'escape_utils/erb' # to patch ERB::Util
35
- require 'escape_utils/cgi' # to patch CGI
36
- require 'escape_utils/haml' # to patch Haml::Helpers
44
+ require 'escape_utils/javascript/action_view' # to patch ActionView::Helpers::JavaScriptHelper
37
45
 
38
46
  == Benchmarks
39
47
 
@@ -42,7 +50,9 @@ While unescaping is around 20-40x faster than CGI.unescapeHTML - also pure ruby.
42
50
 
43
51
  This output is from my laptop using the benchmark scripts in the benchmarks folder.
44
52
 
45
- === HTML Escaping
53
+ === HTML
54
+
55
+ ==== Escaping
46
56
 
47
57
  Rack::Utils.escape_html
48
58
  0.560000 0.040000 0.600000 ( 0.589475)
@@ -55,14 +65,16 @@ This output is from my laptop using the benchmark scripts in the benchmarks fold
55
65
  EscapeUtils.escape_html
56
66
  0.050000 0.010000 0.060000 ( 0.054799)
57
67
 
58
- === HTML Unescaping
68
+ === Unescaping
59
69
 
60
70
  CGI.unescapeHTML
61
71
  1.140000 0.010000 1.150000 ( 1.148470)
62
72
  EscapeUtils.unescape_html
63
73
  0.040000 0.000000 0.040000 ( 0.046166)
64
74
 
65
- === Javascript Escaping
75
+ === Javascript
76
+
77
+ ==== Escaping
66
78
 
67
79
  ActionView::Helpers::JavaScriptHelper#escape_javascript
68
80
  2.000000 0.020000 2.020000 ( 2.023047)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{escape_utils}
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brian Lopez"]
@@ -29,10 +29,11 @@ Gem::Specification.new do |s|
29
29
  "ext/escape_utils.c",
30
30
  "ext/extconf.rb",
31
31
  "lib/escape_utils.rb",
32
- "lib/escape_utils/cgi.rb",
33
- "lib/escape_utils/erb.rb",
34
- "lib/escape_utils/haml.rb",
35
- "lib/escape_utils/rack.rb",
32
+ "lib/escape_utils/html/cgi.rb",
33
+ "lib/escape_utils/html/erb.rb",
34
+ "lib/escape_utils/html/haml.rb",
35
+ "lib/escape_utils/html/rack.rb",
36
+ "lib/escape_utils/javascript/action_view.rb",
36
37
  "spec/html/escape_spec.rb",
37
38
  "spec/html/unescape_spec.rb",
38
39
  "spec/javascript/escape_spec.rb",
@@ -4,5 +4,5 @@ require 'escape_utils_ext'
4
4
 
5
5
  EscapeUtils.send(:extend, EscapeUtils)
6
6
  module EscapeUtils
7
- VERSION = "0.1.1"
7
+ VERSION = "0.1.2"
8
8
  end
File without changes
File without changes
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ module ActionView
4
+ module Helpers
5
+ module JavaScriptHelper
6
+ def escape_javascript(s)
7
+ EscapeUtils.escape_javascript(s)
8
+ end
9
+ end
10
+ end
11
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Brian Lopez
@@ -40,10 +40,11 @@ files:
40
40
  - ext/escape_utils.c
41
41
  - ext/extconf.rb
42
42
  - lib/escape_utils.rb
43
- - lib/escape_utils/cgi.rb
44
- - lib/escape_utils/erb.rb
45
- - lib/escape_utils/haml.rb
46
- - lib/escape_utils/rack.rb
43
+ - lib/escape_utils/html/cgi.rb
44
+ - lib/escape_utils/html/erb.rb
45
+ - lib/escape_utils/html/haml.rb
46
+ - lib/escape_utils/html/rack.rb
47
+ - lib/escape_utils/javascript/action_view.rb
47
48
  - spec/html/escape_spec.rb
48
49
  - spec/html/unescape_spec.rb
49
50
  - spec/javascript/escape_spec.rb