TinyPortal

Development => Support => Topic started by: wildenborch on October 16, 2018, 07:39:38 PM

Title: Special characters in the article subject
Post by: wildenborch on October 16, 2018, 07:39:38 PM
Hi, I just noticed on my brothers website that special characters like é è ö etc are saved correctly and can also been seen in the published article but when editing the saved article, the subject is completely empty.
When you save the article without changing the subject the subject will be empty.
The language settings on his site in English (not utf-8) and the database is Latin Swedish Ci

When I change the language to English UTF-8 and use these special characters and save the article the subject is visible when editing the article.

So I can simply solve this by changing the language to English UTF but then all old articles are showing strange charecters like Myl�ne Farmer's new album is called D�sob�issance.
Not only in the subject but also in the article body so this is not really an option.

Is another solution possible?

Title: Re: Special characters in the article subject
Post by: @rjen on October 16, 2018, 08:07:33 PM
mmm, is this new? It seems like something that was there in previous versions too...
Title: Re: Special characters in the article subject
Post by: wildenborch on October 16, 2018, 08:17:32 PM
This also happened in previous versions.
I just checked it in 1.50!

I know, I should have posted this in the support section....
I have now moved this topic to support
Title: Re: Special characters in the article subject
Post by: tino on October 16, 2018, 08:18:33 PM
You have to update your forum locale as well as the database if you switch to UTF8
Title: Re: Special characters in the article subject
Post by: wildenborch on October 16, 2018, 08:21:42 PM
What do you mean with locale?
Title: Re: Special characters in the article subject
Post by: wildenborch on October 16, 2018, 08:33:05 PM
But isn't it strange that the subject is empty after saving the article?
Looks a bit like the problem I had with " " in the subject.
https://www.tinyportal.net/index.php?topic=36070.msg293069#msg293069 (https://www.tinyportal.net/index.php?topic=36070.msg293069#msg293069)

Tino, it looks like the change to accept "" has created this problem on my brothers website. I replaced

<input style="width: 92%;" name="tp_article_subject" type="text" value="'. htmlentities($mg['subject'], ENT_QUOTES) .'">

with the old code
<input style="width: 92%;" name="tp_article_subject" type="text" value="'. $mg['subject'] .'">

and now the special characters are accepted and after saving also visiable when editing the article.

Unfortunately, now the text between and after "" and is now removed.
Title: Re: Special characters in the article subject
Post by: tino on October 16, 2018, 09:22:06 PM
html_entity_decode might work better.

Try it with html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)

Or if its UTF8 html_entity_decode($mg['subject'], ENT_QUOTES, UTF-8)
Title: Re: Special characters in the article subject
Post by: wildenborch on October 16, 2018, 09:30:03 PM
Thanks Tino,

html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)

did the trick!

Is this something I should change after each update or is this something that will be included in future releases?
For now it's on my list for files to change after an update.
Title: Re: Special characters in the article subject
Post by: tino on October 16, 2018, 09:40:45 PM
Quote from: wildenborch on October 16, 2018, 09:30:03 PM
Thanks Tino,

html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)

did the trick!

Is this something I should change after each update or is this something that will be included in future releases?
For now it's on my list for files to change after an update.

I'll work out a more generic function for it in the next release.
Title: Re: Special characters in the article subject
Post by: tino on October 16, 2018, 10:33:06 PM
Quote from: wildenborch on October 16, 2018, 09:30:03 PM
Thanks Tino,

html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)

did the trick!

Is this something I should change after each update or is this something that will be included in future releases?
For now it's on my list for files to change after an update.

Can you also try with this;


un_htmlspecialchars($mg['subject'])


If we can use the built in SMF one then it makes it easier.
Title: Re: Special characters in the article subject
Post by: wildenborch on October 17, 2018, 01:14:29 PM
Hi Tino,

This code is working for the special characters but the text after and including " is removed.

This is also happening with
html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)


I also tried it with this code
un_htmlspecialchars($mg['subject'], ENT_QUOTES)
But this does not solve the " problem.
Title: Re: Special characters in the article subject
Post by: tino on October 17, 2018, 07:11:04 PM
Quote from: wildenborch on October 17, 2018, 01:14:29 PM
Hi Tino,

This code is working for the special characters but the text after and including " is removed.

This is also happening with
html_entity_decode($mg['subject'], ENT_QUOTES, ISO-8859-15)


I also tried it with this code
un_htmlspecialchars($mg['subject'], ENT_QUOTES)
But this does not solve the " problem.

Thanks, I'll get this fixed for 1.6.1
Title: Re: Special characters in the article subject
Post by: wildenborch on October 17, 2018, 10:22:31 PM
Tino,

I think the problem was caused by a corrupt file because after I renamed the sources directory and copied the Sources directory from a fresh SMF + Tinyportal 1.60 install the problem is no longer there.

Please ignore the above.
The problem is still there.


Title: Re: Special characters in the article subject
Post by: wildenborch on October 18, 2018, 12:54:47 PM
Upon some further checking I noticed that on the website with this behaviour, the settings.php file does not have $db_character_set = 'utf8';
All other websites I have do have this code in the settings.php.

After adding this code in the settings.php file the special characters are accepted.

Hopefully this is tomorrow still the same and of not I will striketrough this above sentence as well :)