aboutsummaryrefslogtreecommitdiffstats
path: root/test/rexml
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-02-09 20:33:06 +0000
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2019-08-04 11:54:50 +0900
commitee8985ef0e35183d606af3a7360cd4713069e9b2 (patch)
tree9d3f4ea01854683d3dd7faba42d1873070c3cba6 /test/rexml
parent982208c65069423b1bc90dafde7589872c452c21 (diff)
downloadruby-ee8985ef0e35183d606af3a7360cd4713069e9b2.tar.gz
[ruby/rexml] Fix crash with nil XPath variables (#13)
Patch by Alyssa Ross. Thanks!!! https://github.com/ruby/rexml/commit/2a53c54f58
Diffstat (limited to 'test/rexml')
-rw-r--r--test/rexml/test_functions.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/rexml/test_functions.rb b/test/rexml/test_functions.rb
index a77be38cc1..c1716ebe1c 100644
--- a/test/rexml/test_functions.rb
+++ b/test/rexml/test_functions.rb
@@ -6,6 +6,12 @@ require "rexml/document"
module REXMLTests
class FunctionsTester < Test::Unit::TestCase
include REXML
+
+ def setup
+ super
+ REXML::Functions.context = nil
+ end
+
def test_functions
# trivial text() test
# confuse-a-function
@@ -222,6 +228,19 @@ module REXMLTests
assert_equal( [REXML::Comment.new("COMMENT A")], m )
end
+ def test_string_nil_without_context
+ doc = REXML::Document.new(<<-XML)
+ <?xml version="1.0" encoding="UTF-8"?>
+ <root>
+ <foo bar="baz"/>
+ <foo bar=""/>
+ </root>
+ XML
+
+ m = REXML::XPath.match(doc, "//foo[@bar=$n]", nil, { "n" => nil })
+ assert_equal( 1, m.size )
+ end
+
def test_unregistered_method
doc = Document.new("<root/>")
assert_nil(XPath::first(doc.root, "to_s()"))