active_shipping
active_shipping copied to clipboard
UPS using '®' in API responses, causing REXML::ParseException
I'm using ruby 1.9.3p545 and active_shipping 0.12.3.
UPS seems to have started including the '®' symbol in reporting activity of packages. It appears that this is causing an error when active_shipping tries to parse the API response.
Example shipment: 1ZW69Y250398445209
Screenshot: 
Calling find_tracking_info for this tracking number results in the following stack trace:
REXML::ParseException: #<REXML::ParseException: #<ArgumentError: invalid byte sequence in UTF-8>
/usr/lib64/ruby/1.9.1/rexml/source.rb:210:in `match'
/usr/lib64/ruby/1.9.1/rexml/source.rb:210:in `match'
/usr/lib64/ruby/1.9.1/rexml/parsers/baseparser.rb:419:in `pull_event'
/usr/lib64/ruby/1.9.1/rexml/parsers/baseparser.rb:183:in `pull'
/usr/lib64/ruby/1.9.1/rexml/parsers/treeparser.rb:22:in `parse'
/usr/lib64/ruby/1.9.1/rexml/document.rb:245:in `build'
/usr/lib64/ruby/1.9.1/rexml/document.rb:43:in `initialize'
/data/food52/shared/bundled_gems/ruby/1.9.1/gems/active_shipping-0.12.3/lib/active_shipping/shipping/carriers/ups.rb:323:in `new'
/data/food52/shared/bundled_gems/ruby/1.9.1/gems/active_shipping-0.12.3/lib/active_shipping/shipping/carriers/ups.rb:323:in `parse_tracking_response'
/data/food52/shared/bundled_gems/ruby/1.9.1/gems/active_shipping-0.12.3/lib/active_shipping/shipping/carriers/ups.rb:121:in `find_tracking_info'
[...]
I propose that active_shipping should sanitize the response before creating the REXML::Document, unless REXML provides a way of gracefully handling cases like these.
I ported UPS to use Nokogiri to parse XML. Can you see if this is still an issue?