Permalink
Browse files

now, as builder is gone, we have to sanatize content ourselfes

  • Loading branch information...
1 parent 112c8ed commit c127a7b0028f2ba83dd684a6cba948ece5697eeb Tobias Bielohlawek committed Jan 14, 2011
Showing with 14 additions and 2 deletions.
  1. +1 −1 lib/big_sitemap/builder.rb
  2. +13 −1 test/big_sitemap_test.rb
@@ -106,7 +106,7 @@ def _start_tag(name, attrs = {})
def tag!(name, content, attrs = {})
_indent
_start_tag(name, attrs)
- target!.print content
+ target!.print content.to_s.gsub('&', '&')
_end_tag(name)
_newline
end
View
@@ -186,13 +186,25 @@ def teardown
should 'should generate static content' do
create_sitemap
@sitemap.add_static('/', Time.now, 'weekly', 0.5)
- @sitemap.add_static('/about', Time.now, 'weekly', 0.5).generate_static
+ @sitemap.add_static('/about', Time.now, 'weekly', 0.5)
+ @sitemap.generate_static
elems = elements(static_sitemaps_file, 'loc')
assert_equal "/", elems.first.text
assert_equal "/about", elems.last.text
end
end
+ context 'sanatize XML chars' do
+ should 'should transform ampersands' do
+ create_sitemap
+ @sitemap.add_static('/something&else', Time.now, 'weekly', 0.5)
+ @sitemap.generate_static
+ elems = elements(static_sitemaps_file, 'loc')
+ assert Zlib::GzipReader.open(static_sitemaps_file).read.include?("/something&else")
+ assert_equal "/something&else", elems.first.text
+ end
+ end
+
context 'clean method' do
should 'be chainable' do
create_sitemap

0 comments on commit c127a7b

Please sign in to comment.