SOLR-155: Fix field contents escaping (patch provided by Coda Hale)

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@506420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2007-02-12 11:27:01 +00:00
parent 6b81f79ae9
commit e5c7e68e40
2 changed files with 7 additions and 1 deletions

View File

@ -31,7 +31,7 @@ begin
# element.text = "blah" should work
def text=(x)
self.content = x.to_s
self << x.to_s
end
end

View File

@ -21,6 +21,12 @@ class FieldTest < Test::Unit::TestCase
assert_match(/<field name=["']creator["']>Erik Hatcher<\/field>/, field.to_xml.to_s)
end
def test_escaped_xml
field = Solr::Field.new :creator => 'Erik Hatcher & His Amazing Leaping Ability'
assert_kind_of Solr::XML::Element, field.to_xml
assert_match(/<field name=["']creator["']>Erik Hatcher &amp; His Amazing Leaping Ability<\/field>/, field.to_xml.to_s)
end
def test_xml_date
field = Solr::Field.new :time => Time.now
assert_kind_of Solr::XML::Element, field.to_xml