9
epse
3y

Why in the everliving freaking fuck does Java have a class called URLEncoder which DOES NOT DO URL ENCODING??? The shit-spraying piece of a mouldy footgun does formencoding?? Which sadistic maniac thought that was a good idea?

Comments
  • 3
    ๐Ÿคจ

    What part of this is not encoding the string for url usage?

    Utility class for HTML form encoding. This class contains static methods for converting a String to the
    > application/x-www-form-urlencoded
    MIME format

    https://docs.oracle.com/en/java/...
  • 1
    @C0D4 it does form encoding though, not url (percent) encoding. As an example: it will encode a space to a plus character, which is fine in form encoding (or the query part of a url), but not at all correct in the path of a url
  • 2
    @epse fix the endpoint to receive +'s ๐Ÿคท‍โ™‚๏ธ

    But then again, it's a urlencoder not a uri encoder ๐Ÿ˜
  • 1
    @C0D4 that's not "fixing" the endpoint, that's deviating from the url standard just to accommodate a poorly named java class. It's a perfectly fine form encoder, just not a url encoder.

    (there's other differences other than spaces, but I digress)
  • 0
    @epse

    https://docs.oracle.com/javase/8/...

    You'll need URI - see section "Escaped octets, quotation, encoding, and decoding "
  • 0
    @IntrusionCM oh URI has its own footguns, but yes, it does do that bit correctly
  • 1
    @epse honestly it's hard to find a library that does everything right.. Oracle JDK documentation is a nightmare and the standard library sometimes has it's ways of giving severe brain damage, without a doubt… but from my experience there is no perfectness regarding URL -/ URI handling, parsing and encoding in any language.

    Might have something to do with URIs being standardized, but many loopholes exist.

    Caching middleware taught me a lot about it...
  • 1
    @IntrusionCM spring comes with a good library for URI encoding and has relatively decent community docs, but in general I agree with you. Of all languages we use at work, I dread java the most. At least it has Jena, that's very powerful in its field
Add Comment