Support » Plugin: Connections Business Directory » vCard with utf8 BOM

  • Hello,

    thanks for your great tool.

    We got one problem with the vcf Vcard files.

    Since we upgraded your plugin (9.1.1) and php (to 7.3 fpm) the vcards are generatet in Utf8 with BOM.
    This destroys the vCard’s. When you open the file and save it to UTF8 without BOM everything is ok.

    Our Database is on utf8mb4 and wp-config utf8mb4.
    Can you help us with this?

    Tanks and Best regards

    • This topic was modified 3 months, 1 week ago by frachtcontor.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Steven

    (@shazahm1hotmailcom)

    hmmm… odd… I think that the BOM might be applied by the web host as Connections does not add BOM to vCards.

    I dev and test using PHP 7.3.7 so I do not think this is related to the PHP version. And BOM is applied to the beginning of the file contents. The only place BOM is added in Connections is the CSV Export tools. I only added it because Excel can be dumb and not recognize a UTF8 encoded file properly if BOM is not applied.

    Can you share a link to your directory page so I can download a vCard from you site so I can inspect it?

    Thanks for your fast Help! 🙂

    Sure:
    https://www.frachtcontor.com/en/contact/contact-directory/

    click on “Add to Address Book.” to download the vCard.

    Best regards

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Well, BOM is definitely being applied, not that I did not believe you, I did.

    Looking thru the code this in not being applied by Connections.

    Perhaps trying a plugin conflict check… deactivate all other plugins temporarily to see if the issue still persists.

    Hm, I tested it. No luck.
    Updated again php – No luck.
    php.inis are all set to default_charset = "UTF-8"
    Is there something wrong with this Template?
    “Default Entry Card 3.0 by Steven A. Zahm”

    In which function the vCard and the link are generated?

    Another thing is when I try to disable or enable it under entry action nothing happens.
    The vCard link is always visible.

    ??

    Plugin Author Steven

    (@shazahm1hotmailcom)

    RE: Is there something wrong with this Template?

    The template has no function and is not involved in any way with generating and downloading a vCard.

    RE: Another thing is when I try to disable or enable it under entry action nothing happens. The vCard link is always visible.

    This is because the template has been altered. In the “stock” template (as supplied) the vCard link does not exist within the template. It exists as a link above the entry which is only visible when view the single entry profile/detail page which seems to have disabled or removed.

    Here’s a directly link on your site to the single entry profile/detail page:

    https://www.frachtcontor.com/en/contact/contact-directory/name/agnieszka-andrzejewska/

    Here you will see the “Add to Addressbook” action link. That settings controls whether or not that link is visiable.

    RE: In which function the vCard and the link are generated?

    The vCard is generated and downloaded n this function:

    https://github.com/Connections-Business-Directory/Connections/blob/9.1.1/includes/entry/class.entry-vcard.php#L521-L584

    If Connections were adding BOM it would have this code echo "\xEF\xBB\xBF"; before the echo $data; code in the function. Which, as you see, it does not.

    At this point, I suspect the web host is adding the BOM somehow. It may be worth reaching out to their support team. Unfortunately you’ll probably have to get it bumped up a few support levels because I highly doubt the lowers level support team members will understand the issue. At least that is just my experience with tech support when it comes to the more technical issues like these.

    After doing a quick web search, I found this:

    https://stackoverflow.com/questions/6328750/how-do-i-fix-this-php-download-script-which-is-corrupting-files

    It seems PHP might add BOM automatically to the header if the PHP file themselves are saved as UTF8 with BOM. Now, the Connections files are UTF8 but do not have BOM. It is possible when WP installs the Connections, during the unzipping process, that PHP on your server is adding BOM to the files. I would suggest opening one of the plugin files to see if the BOM does exist. If it does, then this might be the cause of the issue. If it is, you would still have to work with your web host to figure out why BOM is being applied to the files when WP installs them.

    I hope this helps, let me know what you learn.

    Thanks for your long post.

    I run out of ideas.
    It’s easy to find all files with BOM: grep -rlI $'\xEF\xBB\xBF' .
    But there is nothing in php….

    The webserver is ok. On other places on the site it works well.
    It delivers evrything with UTF-8.
    Copied the hole vcard class but brings nothing.
    The log shows me

    GET /index.php?id=XX&type=XX&tx_wtdirectory_pi1[vCard]=XXX&cHash=XXXXXXXXXXXXXXXXXXXXXXXX

    I dunno 🙁

    Plugin Author Steven

    (@shazahm1hotmailcom)

    Sorry, I can not think of a single reason why BOM is being applied to vCards. As you see, it is not being applied or added by Connections so I am at a loss as to why and how it is being applied.

    Sorry I can not figure this out for you!

    I guess one thing you could try… in the vCard class in Connections, try manually stripping BOM from $data before it is echo using this function:

    https://stackoverflow.com/a/15423899/5351316

    Run $data thru the function and then echo it.

    If you still get BOM in the vCard then it is the echo that is adding it which means it is PHP adding for some reason.

    If that is the case, before you echo $data start an output buffer using ob_start(), then echo, and then use ob_get_clean() and run that thru the BOM removing function and then echo it again. It’s a bit Rube Goldberg but if PHP is adding it, this *should* remove it.

    I hope that helps, please let me know what your learn.

    Plugin Author Steven

    (@shazahm1hotmailcom)

    @frachtcontor

    Just curious if you had the opportunity to track the hack/work around I suggested in my last reply?

    Hey sorry for the late response. I dont find it out. Just disabled it rebuild the page and test it local, there it worked.

    • This reply was modified 2 days, 22 hours ago by frachtcontor.
Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.