Giter VIP home page Giter VIP logo

Comments (7)

tisba avatar tisba commented on May 30, 2024 2

Follow-Up, see knu/ruby-domain_name#23 (comment) and knu/ruby-domain_name#27

from faraday-follow-redirects.

tisba avatar tisba commented on May 30, 2024 1

This fix has been merged and released upstream, see https://github.com/knu/ruby-domain_name/blob/master/CHANGELOG.md. The domain_name gem in v0.6.20240107 now skips Unicode normalization if the input is strictly ASCII only.

from faraday-follow-redirects.

yykamei avatar yykamei commented on May 30, 2024

The root cause of the error seems to happen when String#unicode_normalize is called. #unicode_normalize is called by domain_name and domain_name is required by http-cookie, which is the dependency of faraday-cookie_jar.

If you remove faraday-cookie_jar from your middleware stack, this error doesn't happen. Hence, the problem seems to be related to faraday-cookie_jar. I think faraday-follow-redirects is not relevant to the error.

from faraday-follow-redirects.

yykamei avatar yykamei commented on May 30, 2024

OK, I misunderstood the situation. response['location'] is already encoded as ASCII-8BIT. I want to look into it further more.

from faraday-follow-redirects.

yykamei avatar yykamei commented on May 30, 2024

response['location'] may come from net-http, which is the default Faraday adapter. net-http parses the response headers using #readuntil internally. #readuntil returns ASCII-8BIT encoded string, so response['location'] is encoded as ASCII-8BIT. Maybe, faraday-follow-redirects should consider the case where the Location header is encoded as ASCII-8BIT.

from faraday-follow-redirects.

yykamei avatar yykamei commented on May 30, 2024

However, I'm not confident faraday-follow-redirects should encode the URL. faraday-follow-redirects will update env[:url] with response['location'] from net-http here. Should env[:url] always be encoded as UTF-8?

Without faraday-cookie_jar, it's fine to assign an ASCII-8BIT string to env[:url] in almost cases. As far as I commented, this might be the matter of domain_name. The same issue is reported here.

knu/ruby-domain_name#23

from faraday-follow-redirects.

tisba avatar tisba commented on May 30, 2024

I need to do some more digging to understand how the ruby-domain_name gem is supposed to work and how things exactly interact.

My current thought process is not to encode anything into UTF-8 for this gem:

  • URLs by definition cannot be unicode.
  • Domains might be encoded in Punycode (RFC3492) but still are always (a subset) ASCII-8bit.
  • Same with the rest of the URL. It's actually not even ASCII, but a printable subset.
  • Browsers (and possibly other clients) might provide the illusion of the path or arguments being in unicode, but they cannot (see e.g. RFC3986).
  • The redirect location from the Location HTTP response header is also ALWAYS in a sub-set of ASCII, see RFC2616 Section 4.2.

Maybe some of the other involved gems do accept UTF-8 encoded domain names for convince, but I'm pretty sure they should always accept and handle ASCII-8BIT too.

from faraday-follow-redirects.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.