From: Stanislav Sedov Date: 2009-06-18T22:21:26+09:00 Subject: [ruby-core:23917] ruby 1.8/1.9 URI merge call for FTP uris is broken. --Signature=_Thu__18_Jun_2009_17_21_18_+0400_kb8nqTXx.+Yjpf+d Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! r16085 in ruby_1_8_7 and subsequent commit in 1.9 broke the URI.merge method for ftp uris. This commit overrided the generic "path" call of the URI class with the method specific to ftp that return the path without leading '/' to conform with FTP RFC. Yet this method is also used internally withing URI module to implement the "merge" method, which now smashes ftp uris. This can be verified by following code: % #!/usr/bin/env ruby % require 'uri' % print URI.parse("ftp://localhost/abc/def/") + "../" % print "\n" For current ruby version this will print ftp://localhostabc/ , which is obviously incorrect. The following patch fixes this for me: --- lib/uri/generic.rb.orig 2009-06-18 16:47:45.000000000 +0400 +++ lib/uri/generic.rb 2009-06-18 16:48:54.000000000 +0400 @@ -1032,7 +1032,15 @@ end end =20 - str << path_query + path =3D path_query + + # + # Add URI delimiter if the path misses it (like as in FTP) + # + if not path.empty? and not str.empty? and path[0, 1] !=3D '/' + path =3D '/' + path=20 + end + str << path end =20 if @fragment Basically, we're checking if we need a separator here, and if we do and the path itself doesn't start with '/' we're adding it explicitly. --=20 Stanislav Sedov ST4096-RIPE --Signature=_Thu__18_Jun_2009_17_21_18_+0400_kb8nqTXx.+Yjpf+d Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJKOj9PAAoJEKN82nOYvCd0iqMP/09u5nWxwSSrgTlaDGqr+5Dx LtCzMxkVBOyc4M18kCWUGshrHH989DP037fdywrQsD69XxTgEObVQitcFylri6yj kOe6C21TLwgJI0qVG7tSyRogv0AjTcgrkIsW9hmDG1qqgTK3g+0LSDAYIrJenWXy oCtBzyec+oBerIPmBHhYLBkzr2JRbEfgf0xYv/qImFebXx2JAf/9vH9rrob3GaJS Go9Xob7R3D251ucBX9YUOy/72lon8u0T2hwmkGfCfTmYESZhibHHB6xfoVp829mI FKUV/V6HoERS+N6QWI8LqeVefs/WF5mDQBYuC5LcgOVvCc6zP9V6OQcWTBXzzzJ4 cJfZ6UzAmxfLGQpQp/UgAeiIyhu+QpP4SwNiqv7SniY3Tkeb922DT9NEB+9YWPas sA2JWFJbxDVQguVhW2cArwFujDHvZQwAgzx9QrXRs4Lp/u6C6Kkl1F+aREO1UbZA AM4sj7IiWjWjbRuLiBq9BTXZdB29OI68ZMs9RAhuqlzV8yqILIbT17bRQlMFYQYn +X0ehnrKnosVIREx/PBKDSpF5JAP/G7bett6itreP+XIC1qmibZBE7Ste4kOmcZu DZ7s2V69V/MTVBcUcQCt7RWk/3CYA1r0+bnUHdyfg0s2K/ToF8/Oz+bKSgsorcJG kEQFFMDciTCP+zLmmwI7 =espx -----END PGP SIGNATURE----- --Signature=_Thu__18_Jun_2009_17_21_18_+0400_kb8nqTXx.+Yjpf+d--