oscarotero / Embed

Get info from any web service or page
MIT License
2.08k stars 310 forks source link

Smart/Curly Quotes Problem (Plus Emojis) #508

Open parrycarry opened 1 year ago

parrycarry commented 1 year ago

I ran across this issue during my testing. I've already added a fix on my end for the quotes, but I figured I'd shed some light on it, perhaps this will help someone else out. This is happening with embed 3.x version... so maybe it isn't an issue in embed 4, but I can't test for that cause the demo page user agent isn't set to the facebook one, so Twitter doesn't return anything. Maybe the problem is Twitter, but I can't really reproduce this.

Anyway, here are some links, using the demo.php page, only adding the new user agent to the dispatcher:

https://api.parrycarry.com/test.php?url=https%3A%2F%2Ftwitter.com%2Fflexinja%2Fstatus%2F1597445652166103040

This one seems to make the smart quotes convert into “ ” and ’, and I assume вЂ˜ is the other apostrophe version when Googling. I've already added a conversion function for this. Twitter descriptions by default all have smart quotes enclosing the actual description, so this should happen to all Tweets, but it doesn't.

https://api.parrycarry.com/test.php?url=https%3A%2F%2Ftwitter.com%2Fflexinja%2Fstatus%2F1595891254155427840

This is from the same person, using the same smart apostrophes, and it doesn't have this problem at all.

https://api.parrycarry.com/test.php?url=https%3A%2F%2Ftwitter.com%2FEevohhh%2Fstatus%2F1597470048033312771

Here is another Tweet from someone else, and it has the same problem again. It also converts the heart 💖 emoji into рџ’–. I haven't added a conversion for this, however, as I just found it.

https://api.parrycarry.com/test.php?url=https%3A%2F%2Ftwitter.com%2Fiamchrisjudge%2Fstatus%2F1597439017448243200

Which is strange cause here is another Tweet with emojis that don't do that.

So, I am not sure what could possible cause this to happen. Sometimes things get converted, and sometimes they don't.

parrycarry commented 1 year ago

I have upgraded to the latest version of Embed via Composer, and this problem is in fact gone. This seems to be strictly an Embed 3.x issue.