javascript_eraser 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/javascript_eraser.rb +2 -0
- data/spec/javascript_eraser_spec.rb +6 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/lib/javascript_eraser.rb
CHANGED
@@ -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:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
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-
|
18
|
+
date: 2010-11-22 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|