Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Sebastiii on April 13, 2022, 04:45:48 PM

Title: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 13, 2022, 04:45:48 PM
Hello,
After migrating SMF forum from 2.0.18 to 2.0.19 topîc with specific char in the name was not loaded anymore.
I have found part of the culprit from load.php :

Original 2.0.18 line 175
$ent_list = empty($modSettings['disableEntityCheck']) ? '&(?>#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(?>#021|quot|amp|lt|gt|nbsp);';
$ent_check = empty($modSettings['disableEntityCheck']) ? function($string, $double = false)
{
$string = preg_replace_callback('~(&' . (!empty($double) ? '(?:amp;)?' : '') . '#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);

Change in 2.0.19 :
$ent_list = empty($modSettings['disableEntityCheck']) ? '&(?>#\d{1,7}|quot|amp|lt|gt|nbsp);' : '&(?>#021|quot|amp|lt|gt|nbsp);';
$ent_check = empty($modSettings['disableEntityCheck']) ? function($string, $double = false)
{
//$string = preg_replace_callback('~(&' . (!empty($double) ? '(?:amp;)?' : '') . '#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
// Restore 2018 version because it broke topic with "'" on word
$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);

The culprit is that line :
$string = preg_replace_callback('~(&' . (!empty($double) ? '(?:amp;)?' : '') . '#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
For example, if we have a topic like this : Le [Journal] d'Astrid
We can see that there is the " ' " without quote, and it wasn't working on 2.0.19.

Maybe there is also other part of the code upgrade that has an issue related.
This is a French SMF version.

Is it enough to only revert that line ?

Thanks for your help
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Kindred on April 13, 2022, 07:22:28 PM
Convert your forum to utf8?

Actually,  iirc, there was an issue with quotes in subjects. I think Shawn determined a patch
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 13, 2022, 07:52:11 PM
Quote from: Kindred on April 13, 2022, 07:22:28 PMConvert your forum to utf8?
It is already in UTF8 :)
The issue start after the upgrade (patch).
I have also apply upgrade.php to migrate db to latest 2.0.19 to see if it solve the issue locally but not !

QuoteActually,  iirc, there was an issue with quotes in subjects. I think Shawn determined a patch
Ah, could be nice to know it, where I can find it ?
Thanks.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: GL700Wing on April 13, 2022, 08:19:23 PM
Are you using the Pretty URLs (https://custom.simplemachines.org/index.php?mod=636) mod?

Another user reported Problems with apostrophes and quotes in the title (https://www.simplemachines.org/community/index.php?topic=580090.0) and it was resolved by updating that mod ...
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 13, 2022, 08:34:32 PM
Quote from: GL700Wing on April 13, 2022, 08:19:23 PMAre you using the Pretty URLs (https://custom.simplemachines.org/index.php?mod=636) mod?
Yes, and it wasn't updated :(

QuoteAnother user reported Problems with apostrophes and quotes in the title (https://www.simplemachines.org/community/index.php?topic=580090.0) and it was resolved by updating that mod ...
It seems to be exactly the same issue, thanks for the link.

Will try to make an upgrade but will be tricky like all packages files from \Packages folder were removed, so updating can't work directly.

I have tried to upgrade locally on 2.0.18, and it was a mess, but it seems that I need to do/try again it then.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Kindred on April 13, 2022, 10:14:17 PM
Why were all packages removed?

You may have to start from clean files and reinstall mods
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 05:15:21 AM
Hi @Kindred ,
One year ago, our admin has cleaned up some folder because (\Package and cache folder) the forum was reachable, only able to go from the server side (SSH / FTP ...)
I don't why it happens but after the cleaning all was working again and a backup was made before at the time but was deleted now.

So, like we start to do some update, now we have seen that \Package folder shouldn't be touched.

So yes starting from clean file is the way to do but like there is many change with many MOD's, it's really not an easy task.

Thanks.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 07:48:26 AM
Hello,
Upgraded to Pretty Urls 2.5 and now it works.
Thanks a lot :)
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Doug Heffernan on April 14, 2022, 07:57:39 AM
Glad to see that the issue got solved. Thank you for letting us know.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 08:13:57 AM
Quote from: Doug Heffernan on April 14, 2022, 07:57:39 AMGlad to see that the issue got solved. Thank you for letting us know.

Maybe I should open a new topic but, I just seen another issue related to quote ' in fact '

When receiving an email for a new post in the forum with text part, now the "'" are coded in "'"

For ex :
Je n'ai pas cherché, j'essaie
instead of :
Je n'ai pas cherché, j'essaie
Before the upgrade to 2.0.19, it was working correctly, I can't double-check locally, because I can't send email from my own windows Wamp server.

So I can't try to figure out if it's related to Pretty Urls or something else. But I think it's maybe related to the Pretty Urls MOD's because received email before the last update to Pretty Urls 2.5 seems working.

Thanks.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Doug Heffernan on April 14, 2022, 08:22:24 AM
Quote from: Sebastiii on April 14, 2022, 08:13:57 AMSo I can't try to figure out if it's related to Pretty Urls or something else. But I think it's maybe related to the Pretty Urls MOD's because received email before the last update to Pretty Urls 2.5 seems working.

Do you have a test 2.0.19 forum installed? If you do not have, you can install one and check if the issue will also occur there, in the freshly installed forum without any mods. If it will, then the chances are it is a bug, if it will not, then most likely it is related to the aforementioned mod, or another third party mod.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 08:25:15 AM
Yes @Doug Heffernan
I have a copy of the site locally (on my PC) and also a fresh 2.0.19 version.
I will try to figure out about sending email setting to make it work locally and will doing some test to try to see where it failed.
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 09:11:05 AM
OK,
I was able to set up SMTP locally based on a copy of the website.
So reverting the line 178 like explain in first post, and it works

$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', $string);
I even tried the one from SMF 2.1.1 :
$string = preg_replace_callback('~(&#(\d{1,7}|x[0-9a-fA-F]{1,6});)~', 'entity_fix__callback', (string) $string);
But it wasn't working !

So will be testing on fresh 2.0.19 forum ;)
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 09:45:53 AM
Ok,

Finally tested on fresh SMF 2.0.19 without plugins, and I'm running into the same issue.
Strangely, not for private message.

So for now, I have to revert to the old 2.0.18 line of code.
All seems to work, so no real clue.

Next step would be to test on latest SMF 2.1.1 to compare :
Title: Re: Issue with specific char in topic name 2.0.18 to 2.0.19
Post by: Sebastiii on April 14, 2022, 10:14:43 AM
Did the test with SMF 2.1.1 and no issue fresh and with Pretty Urls 2.5 :)
So I don't know what to do next, I'll keep with 2.0.18 line code for now, so must be something else in current 2.0.19 !

Thanks.