Project

General

Profile

Bug #11759 » 0001-Do-not-mutate-strings-in-URI-to_s.patch

davidcelis (David Celis), 12/02/2015 01:30 AM

View differences:

lib/uri/generic.rb
#
def to_s
str = ''
if @scheme
str << @scheme
str << ':'.freeze
str = "#{str}#{@scheme}:"
end
if @opaque
str << @opaque
str = "#{str}#{@opaque}"
else
if @host
str << '//'.freeze
str = "#{str}//"
end
if self.userinfo
str << self.userinfo
str << '@'.freeze
str = "#{str}#{self.userinfo}@"
end
if @host
str << @host
str = "#{str}#{@host}"
end
if @port && @port != self.default_port
str << ':'.freeze
str << @port.to_s
str = "#{str}:#{@port}"
end
str << @path
str = "#{str}#{@path}"
if @query
str << '?'.freeze
str << @query
str = "#{str}?#{@query}"
end
end
if @fragment
str << '#'.freeze
str << @fragment
str = "#{str}##{@fragment}"
end
str
end
(1-1/4)