Chaos Engine: I think it’s there for the reason stated in the comment:
// Replace numeric entities because html_entity_decode doesn’t
// do it for us.
But the thing is, it’s an extremely old bit of code, if you look at the git history, and I don’t think that’s true any more. i.e., what I think is going on is that they wrote this code because at the time html_entity_decode did not do what they needed, but now html_entity_decode *does* do what they needed and it’s safe to just replace the custom function with a call to html_entity_decode.
https://ca3.php.net/html_entity_decode explicitly states: “More precisely, this function decodes all the entities (including all numeric entities) that a) are necessarily valid for the chosen document type — i.e., for XML, this function does not decode named entities that might be defined in some DTD — and b) whose character or characters are in the coded character set associated with the chosen encoding and are permitted in the chosen document type. All other entities are left as is.” (emphasis mine)
Of course if I was upstream I’d want to verify this and then patch it up more cleanly by dropping the custom function entirely and replacing all calls to it with calls to html_entity_decode, rather than keeping the custom function as an unnecessary wrapper.
One thing to note, though, is that entity replacement doesn’t seem to be needed all the time – I did throw some debug prints into my change for this and watch the output for a while, and I didn’t actually see any case where the entity replacement did anything while logging in through two or three different OpenID providers – none of the strings that were run through the replaceEntities function actually had any entities to replace, so the string was just getting passed through unmodified. I wasn’t able to find an openID provider which did put HTML entities (especially numeric ones) in the strings that got passed through replaceEntities, to verify that it was working as intended.