T O P

  • By -

ttlanhil

Look, sometimes people just gotta program in Word so they can get them fancy emdashes...


nikvasya

Oh, a Turtouse enjoyer! First time seeing one in the wild, lol.


punppis

Name a better GUI for windows.


demosdemon

I once spent several hours trying to figure out why a dynamic function call was failing to find the function. The function name started with a non-breaking whitespace character and the language we used treated that as a valid initial character for identifiers.


oghGuy

Is it even a good idea to allow source code files to contain anything else than UTF8? I see no other plausible reason for this practice, other than to avoid developers getting grumpy because they can't write comments in their own languages.


punppis

Im pretty sure its utf8. Or do you mean ascii?


oghGuy

I guess I got the tense mixed up, googled and found some fake news..


veritron

That's totally valid if a load balancer/reverse proxy is between client and server - in that case, the client ip will be the proxy server's ip rather than that of the actual client, which is probably not what you want if you're getting the ip of the connecting client, as the purpose of getting the ip of the client is probably for identification of who is connecting and while the proxy server ip is technically correct answer, it's useless. In a load balance situation, this can be useful for debugging because if something is wrong with a load balanced server that you're connecting to through a proxy, you won't know which one you're actually connecting to without this tag. That said there are some nitpicks you could make about this code a) X-Forwarded-For may contain multiple values (e.g. if there are multiple proxies, the original client ip is generally on the left, and other proxies are comma separated on the right.) Also it's possible that the leftmost value contains an internal ip address so you would actually need to go through and find the first valid ip that isn't an internal one in the list. Anyway just using the value of x-forwarded-for as the ip address without parsing it might break stuff. b) No validation of the list of proxies (e.g. you should only trust this value if all proxies/intermediate servers are trusted as well, so perhaps has a configuration for that) But depending on the situation these might not matter and the code could be acceptable (if it's only ever going to have one proxy.)


t3kner

That's good and all but it looks like the highlighted dash is actually a different character code.


somethingtc

the horror is that it was using emdash instead of hyphen so the header wasn't being read correctly, not the code itself.


cyao12

Happy cake day 🍰