lib/addressable/idna/pure.rb in addressable-2.4.0 vs lib/addressable/idna/pure.rb in addressable-2.5.0

- old
+ new

@@ -1,8 +1,8 @@ # encoding:utf-8 #-- -# Copyright (C) 2006-2015 Bob Aman +# Copyright (C) Bob Aman # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -92,10 +92,15 @@ def self.to_unicode(input) input = input.to_s unless input.is_a?(String) parts = input.split('.') parts.map! do |part| if part =~ /^#{ACE_PREFIX}(.+)/ - punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1]) + begin + punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1]) + rescue Addressable::IDNA::PunycodeBadInput + # toUnicode is explicitly defined as never-fails by the spec + part + end else part end end output = parts.join('.')