File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -286,7 +286,7 @@ def self.original_uri_match?(destination_url, settings_url)
286286 # that there all children other than text nodes can be ignored (e.g. comments). If nil is
287287 # passed, nil will be returned.
288288 def self . element_text ( element )
289- element . texts . join if element
289+ element . texts . map ( & :value ) . join if element
290290 end
291291 end
292292 end
Original file line number Diff line number Diff line change @@ -213,5 +213,22 @@ class UtilsTest < Minitest::Test
213213 assert !OneLogin ::RubySaml ::Utils . uri_match? ( destination , settings )
214214 end
215215 end
216+
217+ describe 'element_text' do
218+ it 'returns the element text' do
219+ element = REXML ::Document . new ( '<element>element text</element>' ) . elements . first
220+ assert_equal 'element text' , OneLogin ::RubySaml ::Utils . element_text ( element )
221+ end
222+
223+ it 'returns all segments of the element text' do
224+ element = REXML ::Document . new ( '<element>element <!-- comment -->text</element>' ) . elements . first
225+ assert_equal 'element text' , OneLogin ::RubySaml ::Utils . element_text ( element )
226+ end
227+
228+ it 'returns normalized element text' do
229+ element = REXML ::Document . new ( '<element>element & text</element>' ) . elements . first
230+ assert_equal 'element & text' , OneLogin ::RubySaml ::Utils . element_text ( element )
231+ end
232+ end
216233 end
217234end
You can’t perform that action at this time.
0 commit comments