From 54b7109172bbe36a6702b3844913d715d65ebe9c Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 25 May 2023 11:29:15 +0900 Subject: [PATCH] xpath: fix a bug that #abbreviate can't handle function arguments GitHub: fix GH-95 Reported by pulver. Thanks!!! --- lib/rexml/parsers/xpathparser.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/rexml/parsers/xpathparser.rb b/lib/rexml/parsers/xpathparser.rb index d92678fe..afff85ce 100644 --- a/lib/rexml/parsers/xpathparser.rb +++ b/lib/rexml/parsers/xpathparser.rb @@ -170,7 +170,10 @@ def predicate_to_string( path, &block ) name = path.shift string << name string << "( " - string << predicate_to_string( path.shift, &block ) + path.shift.each_with_index do |argument, i| + string << ", " if i > 0 + string << predicate_to_string(argument, &block) + end string << " )" when :literal path.shift