Giter Club home page Giter Club logo

Comments (6)

mbabker avatar mbabker commented on August 17, 2024

This sounds like a case where you would need to handle any required encoding to me after the URI class creates the string, I don't think this is something that you can address in a generally reusable abstraction class. Using the example within the HTML context, you're right in that it would be best if special characters were encoded. BUT, considering the URI class is used in other non-HTML contexts, assuming that the resulting URL should be encoded for a specific scenario isn't the best of ideas. That assumption could very well break the Framework's HTTP package as an example, which leads to other breakages in other systems.

So any change proposal needs to tread very carefully.

from uri.

mbabker avatar mbabker commented on August 17, 2024

#21 has a past attempt at dealing with encoding.

from uri.

sakiss avatar sakiss commented on August 17, 2024

Thanks for the feedback!

When the query contains reserved characters, those should not be encoded, no matter the usage?
https://tools.ietf.org/html/rfc3986#section-2.2

from uri.

mbabker avatar mbabker commented on August 17, 2024

To be honest, I don't know the RFCs well enough in that regard to say what the absolute "right" behavior is. The way the RFC reads is that encoding is only mandatory if it doesn't conflict with a character's other use in that segment of a URI, so & only requires encoding if you're trying to pass that character inside the value of something in a query string, but doesn't seem to require encoding in the path or fragment segments (and I'll say I'm either completely over-simplifying this or am completely wrong here, but like I said, I'm clueless on what the "right" thing is).

Maybe bounce things off of how Laminas or Guzzle implement their PSR-7 URI classes, and see if there's something in those implementations that can set a guideline on how to change things here.

from uri.

sakiss avatar sakiss commented on August 17, 2024

The way the RFC reads is that encoding is only mandatory if it doesn't conflict with a character's other use in that segment of a URI, so & only requires encoding if you're trying to pass that character inside the value of something in a query string.

This sounds reasonable and seems to be backed by the RFC3986.

but doesn't seem to require encoding in the path or fragment segments (and I'll say I'm either completely over-simplifying this or am completely wrong here, but like I said, I'm clueless on what the "right" thing is)

I think that the limitations apply in every component (except the host, the port and the user) and this seem to happen in the Guzzle:PSR7 class and the laminas as well.

Though i am not sure if the encoding should be done in every non-ascii character or just the reserved. Given that W3 encourages the use of UTF-8 characters (IRIs) and most web browsers (see example) do the encoding automatically for non reserved characters (not sure about other clients). Sites like wikipedia use IRIs since years.

from uri.

sakiss avatar sakiss commented on August 17, 2024

@mbabker If we set some specs and this has chances to be merged in J4, i can contribute.

from uri.

Related Issues (4)

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.