Skip to main content


Okay, so why does this happen? Here's a silly example. 039;You will be my dinner039; the alien said to the old man.
#039
in reply to Matt Campbell

@matt Yeah but why do some news outlets put text like that on their Mastodon posts?
in reply to Jayson Smith

Because we web developers still suck at reliably generating correct HTML. A lot of us learned, back when we were working with interpreted languages on much slower computers, that generating HTML the sensible way, by calling functions to generate one tag at a time, was slow. So we've been doing string concatenation with sloppy escaping instead, for like 25+ years. I'd venture to say it's still particularly a problem in PHP.
in reply to Matt Campbell

Or, in the case you're talking about, it's possible that the content was escaped for HTML on its way into the database, on the assumption that it would be going into a web page, and then used in a context where that pre-escaping wasn't needed. That at least used to be a common pattern in PHP, "sanitizing" data at input time rather than escaping it at output time for the specific output format.
Unknown parent

Sean Randall
@mcourcel well %20 makes sense because you can't encode a space in a URL.
Unknown parent

Martin in Toronto
@cachondo Yeah, that's usually when something doesn't understand the character and generates this crap. It's like the %20 that you sometimes see in wbe addresses.