lib/flexirest/request.rb in flexirest-1.12.0 vs lib/flexirest/request.rb in flexirest-1.12.1
- old
+ new
@@ -127,10 +127,14 @@
end
ret
end
def inject_basic_auth_in_url(url)
- url.gsub!(%r{//(.)}, "//#{username}:#{password}@\\1") if !url[%r{//[^/]*:[^/]*@}]
+ u = username
+ u = CGI::escape(u) if u.present? && !u.include?("%")
+ p = password
+ p = CGI::escape(p) if p.present? && !p.include?("%")
+ url.gsub!(%r{//(.)}, "//#{u}:#{p}@\\1") if !url[%r{//[^/]*:[^/]*@}]
end
def using_basic_auth?
!!username
end