loofah 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of loofah might be problematic. Click here for more details.

data.tar.gz.sig CHANGED
Binary file
@@ -1,5 +1,11 @@
1
1
  = Changelog
2
2
 
3
+ == 0.3.1 (2009-10-12)
4
+
5
+ Bug fixes:
6
+
7
+ * Scrubbed Documents properly render html, head and body tags when serialized.
8
+
3
9
  == 0.3.0 (2009-10-06)
4
10
 
5
11
  Enhancements:
data/Rakefile CHANGED
@@ -29,6 +29,7 @@ else
29
29
  end
30
30
 
31
31
  task :redocs => :fix_css
32
+ task :docs => :fix_css
32
33
  task :fix_css do
33
34
  better_css = <<-EOT
34
35
  .method-description pre {
@@ -159,7 +159,7 @@ require 'loofah/helpers'
159
159
  #
160
160
  module Loofah
161
161
  # The version of Loofah you are using
162
- VERSION = '0.3.0'
162
+ VERSION = '0.3.1'
163
163
 
164
164
  # The minimum required version of Nokogiri
165
165
  REQUIRED_NOKOGIRI_VERSION = '1.3.3'
@@ -19,6 +19,14 @@ module Loofah
19
19
  end
20
20
  end
21
21
 
22
+ #
23
+ # Returns the HTML markup contained by the fragment or document
24
+ #
25
+ def to_s
26
+ __sanitize_roots.children.to_s
27
+ end
28
+ alias :serialize :to_s
29
+
22
30
  private
23
31
 
24
32
  def __sanitize_roots # :nodoc:
@@ -23,14 +23,6 @@ module Loofah
23
23
  self
24
24
  end
25
25
 
26
- #
27
- # Returns the HTML markup contained by the fragment or document
28
- #
29
- def to_s
30
- __sanitize_roots.children.to_s
31
- end
32
- alias :serialize :to_s
33
-
34
26
  #
35
27
  # Returns a plain-text version of the markup contained by the fragment or document
36
28
  #
@@ -65,7 +65,7 @@ class TestAdHoc < Test::Unit::TestCase
65
65
 
66
66
  def test_whitewash_on_fragment
67
67
  html = "safe<frameset rows=\"*\"><frame src=\"http://example.com\"></frameset> <b>description</b>"
68
- whitewashed = Loofah.scrub_document(html, :whitewash).to_s
68
+ whitewashed = Loofah.scrub_document(html, :whitewash).xpath("/html/body/*").to_s
69
69
  assert_equal "<p>safe</p><b>description</b>", whitewashed.gsub("\n","")
70
70
  end
71
71
 
@@ -135,24 +135,15 @@ mso-bidi-language:#0400;}
135
135
  <p class="MsoNormal">Foo <b style="">BOLD<o:p></o:p></b></p>
136
136
  EOHTML
137
137
 
138
- def test_deprecated_whitewash_fragment_on_microsofty_markup
139
- whitewashed = Loofah.scrub_fragment(MSWORD_HTML.chomp, :whitewash).to_s
140
- assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed
141
- end
142
-
143
- def test_deprecated_whitewash_on_microsofty_markup
144
- whitewashed = Loofah.scrub_document(MSWORD_HTML, :whitewash).to_s
145
- assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed
146
- end
147
-
148
138
  def test_fragment_whitewash_on_microsofty_markup
149
- whitewashed = Loofah.fragment(MSWORD_HTML.chomp).scrub!(:whitewash)
139
+ whitewashed = Loofah.fragment(MSWORD_HTML).scrub!(:whitewash)
150
140
  assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.to_s
151
141
  end
152
142
 
153
143
  def test_document_whitewash_on_microsofty_markup
154
- whitewashed = Loofah.document(MSWORD_HTML.chomp).scrub!(:whitewash)
155
- assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.to_s
144
+ whitewashed = Loofah.document(MSWORD_HTML).scrub!(:whitewash)
145
+ assert_contains whitewashed.to_s, %r(<p>Foo <b>BOLD</b></p>)
146
+ assert_equal "<p>Foo <b>BOLD</b></p>", whitewashed.xpath("/html/body/*").to_s
156
147
  end
157
148
 
158
149
  def test_return_empty_string_when_nothing_left
@@ -97,4 +97,29 @@ class TestScrubber < Test::Unit::TestCase
97
97
  Loofah.scrub_document(:string_or_io, :method)
98
98
  end
99
99
 
100
+ def test_document_to_s
101
+ doc = Loofah.scrub_document "<html><head><title>quux</title></head><body><div>foo</div></body></html>", :prune
102
+ assert_not_nil doc.xpath("/html").first
103
+ assert_not_nil doc.xpath("/html/head").first
104
+ assert_not_nil doc.xpath("/html/body").first
105
+
106
+ assert_contains doc.to_s, /<!DOCTYPE/
107
+ assert_contains doc.to_s, /<html>/
108
+ assert_contains doc.to_s, /<head>/
109
+ assert_contains doc.to_s, /<body>/
110
+ end
111
+
112
+ def test_document_serialize
113
+ doc = Loofah.scrub_document "<html><head><title>quux</title></head><body><div>foo</div></body></html>", :prune
114
+
115
+ assert_not_nil doc.xpath("/html").first
116
+ assert_not_nil doc.xpath("/html/head").first
117
+ assert_not_nil doc.xpath("/html/body").first
118
+
119
+ assert_contains doc.serialize, /<!DOCTYPE/
120
+ assert_contains doc.serialize, /<html>/
121
+ assert_contains doc.serialize, /<head>/
122
+ assert_contains doc.serialize, /<body>/
123
+ end
124
+
100
125
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loofah
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -31,7 +31,7 @@ cert_chain:
31
31
  FlqnTjy13J3nD30uxy9a1g==
32
32
  -----END CERTIFICATE-----
33
33
 
34
- date: 2009-10-06 00:00:00 -04:00
34
+ date: 2009-10-12 00:00:00 -04:00
35
35
  default_executable:
36
36
  dependencies:
37
37
  - !ruby/object:Gem::Dependency
metadata.gz.sig CHANGED
Binary file