handle UTF-16 error on ruby 2.2

Change-Id: I4fff1e2963d2a5eb3d544b546b2eada0f4b106b2
Reviewed-on: https://gerrit.instructure.com/56058
Tested-by: Jenkins
Reviewed-by: James Williams  <jamesw@instructure.com>
Product-Review: Cody Cutrer <cody@instructure.com>
QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
Cody Cutrer 2015-06-09 16:04:00 -06:00
parent 6a79b50f11
commit a91fa7d440
1 changed files with 5 additions and 0 deletions

View File

@ -100,7 +100,12 @@ module XMLHelper
if doc.encoding != 'UTF-8'
begin
doc.at_css('*')
rescue ArgumentError => e
# ruby 2.2
raise unless e.message =~ /^invalid byte sequence/
doc.encoding = 'UTF-8'
rescue Encoding::CompatibilityError
# ruby 2.1
doc.encoding = 'UTF-8'
end
end