Entries with accents or strange characters rejected

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
Richard
Posts: 1
Joined: Fri Jul 17, 2015 6:41 am

Entries with accents or strange characters rejected

Post by Richard »

Script URL: http://www.richardackermann.ch/gbook/gbook.php
Version of script: 1.7.2 and 1.5
Hosting company: Webopolis Switzerland
URL of phpinfo.php: --
URL of session_test.php: --
What terms did you try when SEARCHING for a solution:
PHP 5.4 guest book accents strange characters

Write your message below:

Hello!

The server hosting my guestbook was recently updated to PHP 5.4, and ever since every attempt to sign the guestbook with a text containing either accents or strange characters (such as ö/ä/ü or é/à/ô) is rejected: the entry field is cleared and the warning message says "please enter your comment".

However, old comments written with accents are still correctly displayed in the guest book.

Of course, this is not an issue for English speaking visitors, but my website is in English-German-French...

I am still using version 1.5 on my website (who worked perfectly fine until the PHP update), but to run a test on this issue, I updated it temporarily to the latest version 1.7.2., with the same result :(

Any idea where the culprit is? Is version 1.7.2. compatible with PHP 5.4?

Thanks for your precious help!

Richard (Switzerland)
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

Hello,

Could you please try this and let me know if it fixes your issue:

1. open gbook.php in a text editor
2. find line

Code: Select all

$in = htmlspecialchars($in);
3. change it to:

Code: Select all

$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
4. Save, upload and test.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
the fool on the hill
Posts: 6
Joined: Sat Oct 20, 2012 8:09 pm

Re: Entries with accents or strange characters rejected

Post by the fool on the hill »

Hi, I'm using 1.7 in French and I have the same problem. I changed the line of code as suggested and that allowed the poster to submit. But not all accents are recognised. For example û is fine but ô is not. I edited the post manually and then noticed that all existing posts were affected, ie some letters are replaced by nonsense.

Is there a solution ?
Thanks in advance - The Fool
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

Looks like the script needs to be updated to use UTF-8 encoding.

I will try to prepare an update as soon as possible, probably in the next few weeks.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jokus08
Posts: 4
Joined: Thu Mar 10, 2016 4:16 am

Re: Entries with accents or strange characters rejected

Post by Jokus08 »

I just registered to stop by in this particular thread. Has there been any progress in this matter?

I installed GBook 1.72 on my site and customized the css, only to find out afterwards that I cannot use it in my language area. D'oh! :D
"Ää", "Öö", "Üü" and "ß" all turn into "ďż˝"... Without the

Code: Select all

$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
fix from above, GBook would not even accept any entry including these umlauts at all. Took me a while to figure out what was going on!

From what I can tell GBook is a great piece of software. I just wish this major flaw could get sorted out as soon as possible. As it stands right now a large part of the user base is locked out from using it. Or am I doing something wrong?
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

The underlying fault is in actually in PHP itself, when they changed the default settings and modified the way htmlspecialchars function works. It's been discussed and frowned upon a lot in the PHP community (with the dreaded "it's not a bug, it's a feature" excuse from PHP core developers), especially because the htmlspecialchars doesn't even generate an error or a notice, just discards all the text.

Anyway, I know an update to GBook is long due. I am currently finishing a complete rewrite of LinkMan and will work on getting GBook updated next.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jokus08
Posts: 4
Joined: Thu Mar 10, 2016 4:16 am

Re: Entries with accents or strange characters rejected

Post by Jokus08 »

Thank you for the quick reply and all the great software you provide us with! Do you think the character set problem can be solved in your next release?

I know next to nothing about php but would it be possible to implement a dirty fix for the time being that replaces a given set of characters with acceptable ones at the time of submitting the comment? Something along the lines of this javascript function:

Code: Select all

str.replace(/ö/g, "oe")
The results would still be kind of awkward, but the character replacements ä -> ae, ö -> oe, ü -> ue, ß -> ss are somewhat accepted over here.

It would help bridge the time till your new release will be out. And one could always go manually over the entries.txt file with "search & replace" afterwards, filling in the original characters once the new GBook copes with this character problem.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

The char problem will definitely be solved in the next release as the entire GBook will move to UTF-8 encoding.

Can you post the URL of your guestbook and phpinfo.php file on your server?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jokus08
Posts: 4
Joined: Thu Mar 10, 2016 4:16 am

Re: Entries with accents or strange characters rejected

Post by Jokus08 »

Hello, the site is not officially live yet, so I'd prefer to send you the link in a pm. Hope that's ok with you! I'm always ready to help you out with testing if you need someone.
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

Here is the full solution for anyone having the same problem (will also be included in the future update):

1. Download and install this free but powerful text editor: Notepad++

2. open file gbook.php in Notepadd++

3. find line

Code: Select all

$in = htmlspecialchars($in);
4. change it to:

Code: Select all

$in = htmlspecialchars($in, ENT_COMPAT | ENT_SUBSTITUTE | ENT_XHTML, 'UTF-8');
5. Save changes to gbook.php

6. Open file language.inc.php file in Notepad++

7. in top menu click "Encoding" > "Convert to UTF-8" (the option without "BOM")

8. change line

Code: Select all

$lang['enc']='windows-1250';
to

Code: Select all

$lang['enc']='utf-8';
9. save the file and upload to the server

10. open guestbook in browser, refresh it and submit a new test post
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Jokus08
Posts: 4
Joined: Thu Mar 10, 2016 4:16 am

Re: Entries with accents or strange characters rejected

Post by Jokus08 »

Stellar work, thank you Klemen for the support ! Everything is working fine now. I'm not even sure a company with an expensive maintenance contract would have come up with a fix this quick 8)
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Re: Entries with accents or strange characters rejected

Post by Klemen »

You are welcome, thank you for testing this for me.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
einarkol
Posts: 4
Joined: Fri Mar 11, 2016 10:43 pm

Re: Entries with accents or strange characters rejected

Post by einarkol »

Try saving your files in: UTF-8 - NO BOM

It did the trick for me.

Einar
Post Reply