We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d676c18 commit d436705Copy full SHA for d436705
lib/oai/client.rb
@@ -251,6 +251,7 @@ def load_document(xml)
251
end
252
when 'rexml'
253
begin
254
+ xml = strip_invalid_xml_chars(xml)
255
return REXML::Document.new(xml)
256
rescue REXML::ParseException => e
257
raise OAI::Exception, 'response not well formed XML: '+e.message, caller
@@ -354,5 +355,18 @@ def strip_invalid_utf_8_chars(xml)
354
355
xml
356
357
358
+ def strip_invalid_xml_chars(xml)
359
+ invalid = false
360
+
361
+ begin
362
+ REXML::Document.new(xml)
363
+ rescue REXML::ParseException => e
364
+ invalid = true
365
+ end
366
367
+ return xml.gsub!(/&(?!(?:amp|lt|gt|quot|apos);)/, '&') if invalid
368
+ return xml
369
370
371
372
0 commit comments