[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
Issue #17326 has been reported by jez (Jake Zimmerman).
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:100736] [Ruby master Misc#17309] URI.escape being deprecated, yet there is no replacement
From:
cardoso_tiago@...
Date:
2020-11-07 14:09:28 UTC
List:
ruby-core #100736
Issue #17309 has been updated by chucke (Tiago Cardoso). Hi Jeremy, thx for the context on the inconsistencies, that's pretty useful info. > Can you explain why "http%3A%2F%2Fb%C3%BCcher.ch" is invalid in your use case? My specific use-case is for supporting IDN domain names for HTTP requests in `httpx`, the HTTP client library I maintain (of which "bher.ch" is an example). Because this domain is not ascii, in order to resolve it, I have to first convert it into punycode (you can use this website (https://www.punycoder.com/) to see the translation). When using `httpx`, a user will pass the full request URL: "http://bher.ch" (which I know, it's not a valid URL, because it's not ASCII), so I need to, first, isolate the "host" part of this URL (or IRL), convert it to "punycode", perform the DNS resolution, then perform the HTTP request with the "host/authority" header set to "bher.ch". For a full functional demonstration, you can do the request with cURL and analyse it yourself. This thread I started is all about the first step, "isolating the host part of the IRL". Because the "uri" library doesn't work with IRLs , my workaround is, whenever the URL is not ascii, to: 1. use `URI.escape` to escape the domain into something URI can parse; 2. use URI() to parse into a URI::HTTP object; 3. get host, URI.unescape it, "punycode" it; 4. carry forward both domains, to perform DNS and HTTP requests; If I use `CGI.escape` or any of the suggested alternatives, the resulting escaped string isn't a URL the "uri" library can parse. And this is why I needed the deprecated `URI.escape`. ---------------------------------------- Misc #17309: URI.escape being deprecated, yet there is no replacement https://bugs.ruby-lang.org/issues/17309#change-88381 * Author: chucke (Tiago Cardoso) * Status: Open * Priority: Normal ---------------------------------------- I'm on ruby 2.7.2 . The moment I do ```ruby uri = "http://bher.ch" URI.escape uri (irb):5: warning: URI.escape "http://b%C3%BCcher.ch" ``` I get that warning. Rubocop also tells me: """ URI.escape method is obsolete and should not be used. Instead, use CGI.escape, URI.encode_www_form or URI.encode_www_form_component depending on your specific use case. """ However, none of the suggestions does the same as `URI.escape`. ```ruby CGI.escape uri => "http%3A%2F%2Fb%C3%BCcher.ch" URI.encode_www_form_component uri => "http%3A%2F%2Fb%C3%BCcher.ch" URI.encode_www_form uri Traceback (most recent call last): NoMethodError (undefined method `map' for "http://bher.ch":String) Did you mean? tap ``` So my question is: why is this being deprecated? And if there's still reason, what to exactly replace it for, so I can keep the exact same behaviour? -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>