¤ is evil !

I ran into a funny problem last week with a url from the api of a payment gateway that contained …&currencyCode=…..

I adopted an orphaned codebase and am reprogramming it as WordPress plugin and it contains some really weird bugs. The two previous coders that worked on the codebase opted for an iframe solution through an intermediate page.

Problem is SimpleXml recognizing &curren and converting to ¤ (unicode U+000A4) with ¤cycode= as result, if you tried to relocate the page to that url the gateway rejects the url.

str_replace() does not recognize ¤, the solution I found is first running htmlentities() that replaces ¤ with &curren but also converts & to & which the gateway also rejects, so after using htmlentities() you use str_replace() to replace & with &, and then it works fine.

I am open to suggestions on that one, for now, conclusion is that SimpleXML does not handle &curren in a url correctly, you might run into the same problem with &current_user,  &current_time, et cetera.

Posted in juust and tagged .

Leave a Reply

Your email address will not be published. Required fields are marked *