commit e22fd7e83f33c2a8572ee5939b3365753cd8d062
parent 5728946f67fca5f5b42ea565f04572c643346272
Author: Gaute Hope <eg@gaute.vetsj.com>
Date: Mon, 15 Jul 2013 20:03:16 +0200
Add failing test for bad input to query
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/test/unit/util/test_query.rb b/test/unit/util/test_query.rb
@@ -18,5 +18,24 @@ describe Redwood::Util::Query do
desc = Redwood::Util::Query.describe(query)
_ = (life + desc) # No exception thrown
end
+
+ it "returns a valid UTF-8 description of bad input" do
+ msg = "asdfa \xc3\x28 åasdf"
+ query = Xapian::Query.new msg
+ life = 'hæi'
+
+ # this is now possibly UTF-8 string with possibly invalid chars
+ desc = Redwood::Util::Query.describe (query)
+
+ assert_raises Encoding::CompatibilityError do
+ _ = life + query.description
+ end
+
+ _ = (life + desc)
+
+ # try to do something with string: raises invalid byte sequence
+ _.gsub(/" "/, " ")
+
+ end
end
end