r/PHPhelp • • May 23 '23

php7.3 vs 7.4 utf-8/unicode issue..., when an iPhone is involved.

re-posting..., I missed the r/php rule regarding help requests. Just want to emphasize one point: the DB has been eliminated from the picture. The problem begins at the request.

---

First, apologies for dragging the dead horse into the room. I'll keep it as short as I can, and elaborate if asked.

I'm seeing a problem in a fairly narrow situation. I'm not sure how to further debug this or where to search next. Debugging has removed the DB (MariaDB) from the equation. The problem is independent of the DB.

I have a lamp stack app that functions well with utf-8 and MOST devices/browsers.

I have two deployments. One is a "demo" system, the other is a live system. The demo system predates the live system. The application code is identical on both systems. All configurations, as best as I can determine, are identical ( within version specific limits). All OS packages are installed from the Debian repos.

Demo System:

  • Debian 10

  • PHP7.3

  • Apache 2.4

Live System:

  • Debian 11

  • PHP7.4

  • Apache 2.4

The problem is:

When a user POSTs data containing Unicode emojis using an Android device, or any desktop browser (including anything on a Mac), everything works fine. Characters are decoded to the proper codepoints as seen in $_POST[]. Works on both demo and live systems.

When an iPhone does the same..., it works on the demo system (the older of the two), but not the live system.

Take the character at codepoint #1F606 for example. When an iPhone posts this to the demo system..., it is received and decoded correctly. When an iPhone posts this to the live system, it decodes to #F606.

I've verified that the content-type header includes charset=utf-8..., etc..., all the usual stuff. At this point, the only meaningful difference I can find between the two systems is one is running PHP7.3 (and works correctly with everything) and the other is running PHP7.4 (and fails with the iPhone, but works with everything else).

It was mentioned that locale settings might affect how utf-8 is decoded. I'm following up on that now.

Thoughts on next steps? Thx!

1 Upvotes

4 comments sorted by

1

u/HolyGonzo May 23 '23

I would start by determining if the iPhone is truly sending the data differently or if the data is being handled differently on the receiving (server) side.

The best way to do this would be to set up fiddler on a workstation and ensure it's set up to decrypt https and to permit remote devices to use it as a proxy (and make sure inbound port 8888 is allowed through any local firewall).

Then set up the iPhone to use the workstation IP on port 8888 as its proxy and install the fiddler root certificate on the iPhone. From there, the workstation should be able to see the https traffic from the iPhone's browsing activity and you can use the inspectors to view the raw bytes of data being sent, including any headers that might influence things in any way.

If the raw data is the same when the iPhone posts the emojis to both environments, then that confirms that it's an issue with the receiving / decoding side.

1

u/viewofalake May 23 '23

I may have to go with something like that. I need to get access to an iPhone, cuz at the moment, I'm relying on a user to post test data from their iPhone.

My money is that something is happening on the server side, cuz everything that I CAN see is identical from a client perspective.

Thx!

1

u/Dodo-UA May 23 '23

Have you compared outputs from php -i or phpinfo() between two environments?

2

u/viewofalake May 23 '23

Yes. All config the two releases have in common is the same. The only notable difference wrt 7.4 is the addition of FFI.