javascript_eraser 1.0.1 → 1.0.2

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/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.0.2
@@ -10,6 +10,8 @@ class JavascriptEraser
10
10
  response = ""
11
11
  elsif response.respond_to?(:body) and response.body.is_a?(String)
12
12
  response.body = response.body.gsub(/<script(.|\n)*?type(.|\n)*?javascript(.|\n)*?\/script>/,"")
13
+ response.body = response.body.gsub(/\s*on\w+=".*?[^\\]"\s*(.*?)\s*>/, "\\1>")
14
+ response.body = response.body.gsub(/\s*on\w+='.*?[^\\]'\s*(.*?)\s*>/, "\\1>")
13
15
  elsif response.class.to_s != "Rack::File"
14
16
  puts "JavascriptEraser: unknown response type: #{response.class}. check order of appearance in middleware stack."
15
17
  end
@@ -17,6 +17,12 @@ describe "JavascriptEraser" do
17
17
  je.call(nil)[2].body.should == "blah "
18
18
  end
19
19
 
20
+ it "should erase the event attributes if it's html" do
21
+ class Response; attr_accessor :body; def initialize; @body="blah <div onclick='javascript:doStuff();'></div>"; end; end
22
+ je = JavascriptEraser.new( lambda { |env| [200, {}, Response.new] } )
23
+ je.call(nil)[2].body.should == "blah <div></div>"
24
+ end
25
+
20
26
  it "should log a message if the response type is unknown" do
21
27
  je = JavascriptEraser.new( lambda { |env| [200, {}, {}] } )
22
28
  $stdout.should_receive(:write).at_least(1).times
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: javascript_eraser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tyler Boyd
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-03 00:00:00 -04:00
18
+ date: 2010-11-22 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency