Hacker News new | ask | show | jobs
by Jach 15 days ago
Sure it's the type of bug that could technically occur in any library, being case sensitive when you should have been case insensitive (or done something else not reliant on string case at all), and on its own not that severe, but the whole thing has so much PHP character to it when you take it from the abstract "character case issues happen" to the specific "connections won't use TLS unless the 's' in 'https' is lowercase" (wat). The set of details shape the character. If the URL's host responded over port 80 with a redirect to https, that would work, but you already sent data in the clear with the connection subject to mitm etc. and you get no notice of that. If you tried to be smart and specify an explicit port number, but still had an uppercase S, in the normal case the connection would at least fail and you'd learn about it because PHP wouldn't follow the expected TLS protocol the remote host expects on that port (after already transmitting stuff in the clear). And of course this is all in a language context where you're passing URLs as strings to functions some of which are suggestively named as operating on files, but hey maybe you're passing a stream context so it's a bit more clear you're not doing something with just simple local files. Anything involving a network request can fail in a variety of ways, and oh boy does PHP have a variety of ways of surfacing or not surfacing issues, or trying to continue forward regardless, maybe via trivial implicit type conversions, or via things like following redirects.

I think this article does well at highlighting a lot of the PHP character: https://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ It wasn't a perfect set of criticisms even when it came out (and there were a lot of apologetics in discussions about it) and a bunch of things have changed since 2012, but the character hasn't. Maybe the tersest simplification is just the quote "PHP is a community of amateurs", though I don't think that fully captures it all, and in any case isn't necessarily bad and in many ways can be quite beautiful. But it's part of what gives the whole ecosystem its character and flavor for how things are built with it (and what bugs that surface look like) that other ecosystems don't share, and that character is what I'm getting at with how this particular bug seems like such a PHP thing. Like, spend some time reading up on ridiculous WordPress bugs, some even from this year, and you'll see similar expressions of character. That's not to say you can't find ridiculous bugs in, say, the Java ecosystem, but I think you won't find them as frequently, and when you do you'll more likely see an expression of their separate character as stemming from a bias towards over-abstraction / over-engineering rather than a feeling of amateur hour code slinging.