Skip to content

Commit a2da80f

Browse files
committed
Address warning: URI::RFC3986_PARSER warnings
This commit addresses the following warnings below. ``` /path/to/mail/lib/mail/spec/mail/attachments_list_spec.rb:179: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly. /path/to/mail/lib/mail/spec/mail/utilities_spec.rb:386: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly. /path/to/mail/lib/mail/spec/mail/utilities_spec.rb:390: warning: URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly. /path/to/mail/lib/mail/utilities.rb:160: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly. /path/to/mail/lib/mail/utilities.rb:164: warning: URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly. /path/to/mail/lib/mail/utilities.rb:452: warning: URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly. /path/to/mail/lib/mail/utilities.rb:463: warning: URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly. ``` Ruby 3.4 changes URI::DEFAULT_PARSER to URI::RFC3986_Parser and deprecates some methods. URI::RFC3986_PARSER.make_regexp and URI::RFC3986_PARSER.make_regexp are used in the mail gem. This commit uses URI::RFC2396_PARSER only if it is available for these versions: - uri v0.12.2 for Ruby 3.2/3.1 - uri v0.13.1 for Ruby 3.3 - Ruby 3.4.0dev https://bugs.ruby-lang.org/issues/19266
1 parent 9a7e2bf commit a2da80f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/mail/utilities.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,11 @@ def uri_unescape( str )
165165
end
166166

167167
def uri_parser
168-
@uri_parser ||= URI.const_defined?(:DEFAULT_PARSER) ? URI::DEFAULT_PARSER : URI
168+
@uri_parser ||= if URI.const_defined?(:DEFAULT_PARSER)
169+
defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER
170+
else
171+
URI
172+
end
169173
end
170174

171175
# Matches two objects with their to_s values case insensitively
@@ -464,7 +468,7 @@ def Utilities.param_encode(str)
464468
end
465469

466470
def Utilities.uri_parser
467-
URI::DEFAULT_PARSER
471+
defined?(URI::RFC2396_PARSER) ? URI::RFC2396_PARSER : URI::DEFAULT_PARSER
468472
end
469473

470474
# Pick a Ruby encoding corresponding to the message charset. Most

0 commit comments

Comments
 (0)