TinyPortal

Development => Support => Topic started by: @rjen on April 25, 2021, 08:49:39 PM

Title: If this character & is included in the topic title, then on the block of recent.
Post by: @rjen on April 25, 2021, 08:49:39 PM
Sample posting.

If this character & is included in the topic title, then on the block of recent posts this character is not displayed in the topic title, only &amp is displayed. This is a bug?

Referring to this:
https://www.simplemachines.org/community/index.php?topic=27642.msg4087377#msg4087377
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on April 26, 2021, 07:28:36 AM
Not seeing this issue on my test sites so far. Did you manage to replicate it?
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: @rjen on April 26, 2021, 08:17:32 AM
Quote from: lurkalot on April 26, 2021, 07:28:36 AM
Not seeing this issue on my test sites so far. Did you manage to replicate it?

See the recent topics here...
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on April 26, 2021, 08:57:48 AM
Strange, I looked at this earlier and could have sworn it was ok. I see it now though.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on April 26, 2021, 01:34:23 PM
What does calling ssi_recentPosts directely show? I can't see any where we encode the entity.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: @rjen on April 26, 2021, 01:44:04 PM
https://www.tinyportal.net/ssi_examples.php

it shows correctly..
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 01, 2021, 06:48:20 PM
What is this set to in the database? For me it's this;

Topic with & in it but it display's correctly on the page when rendering.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 01, 2021, 07:04:43 PM
Quote from: tino on May 01, 2021, 06:48:20 PM
What is this set to in the database? For me it's this;

Topic with & in it but it display's correctly on the page when rendering.

You mean the messages table?  MyISAM   utf8_general_ci
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 01, 2021, 07:24:37 PM
And this is what's in the actual database.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 08:50:14 AM
Quote from: lurkalot on May 01, 2021, 07:24:37 PM
And this is what's in the actual database.

Thanks, so it's not double encoded. It's definitely an entity thing. I'll dig a bit more but it's working ok here on my test installs.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 09:24:14 AM
Thanks Tino.  ;)

Strange one, it does it here on this site SMF 2.0.18 TP 2.0.1, but seems to be fine on some other sites running various versions. 

This one running SMF 2.0.17 and TP 1.6.9 is ok, https://cctestsite.info/forums/index.php Until I upgrade it to 2.0.18 then the problem shows up. Roll it back to 2.0.17 and the issue is gone away.

This one is ok. running SMF 2.1 RC3 TP TinyPortal 2.0.1 https://cctestsite.info/testsite3/
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 09:34:46 AM
Edited my post above with new findings. My 2.0.17 test site https://cctestsite.info/forums/index.php is fine until I upgrade it to 2.0.18 then that issue shows up, roll it back and it's gone away again.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 09:54:05 AM
Just tried this on here, and as you can see, rolling back to 2.0.17 seems to cure the problem.

Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 03:34:14 PM
Hmmm I can't recall if my test site was 2.0.18 or 2.0.17.

They messed with the entity logic in that upgrade mind. So that makes sense
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 04:31:29 PM
Quote from: tino on May 02, 2021, 03:34:14 PM
Hmmm I can't recall if my test site was 2.0.18 or 2.0.17.

They messed with the entity logic in that upgrade mind. So that makes sense

This one from the 31st of Jan? "Entity check fix - needs to revert entities for amps in mb4 chars"   

File: Sources/Load.php

Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 05:25:19 PM
It might be that one, you can try it on here with and without that change applied
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 05:46:05 PM
Quote from: tino on May 02, 2021, 05:25:19 PM
It might be that one, you can try it on here with and without that change applied

Think it must be a different one tino, I edited the file but still the same issue.  ;)

(Reverted Change).
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 06:47:31 PM
Hmmm I'm running 2.0.18 and have no issues.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 06:55:54 PM
Quote from: tino on May 02, 2021, 06:47:31 PM
Hmmm I'm running 2.0.18 and have no issues.

Very strange.  It definitely fixes it if I roll back to 2.0.17 This is on here and another site. My test site was actually still on 2.0.17 and that was how I discovered this when I upgraded (patched) it to 2.0.18 the problem was there immediately.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 06:57:12 PM
Give me a minute and I'll uninstall the 2.0.18 patch on here. ;)
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 06:59:09 PM
Rolled back to 2.0.17, if you look at the recent block the issue is gone, or it is for me.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 07:01:49 PM
I can see that also. It's a clean install of 2.0.18 as I trashed all my old instances of TinyPortal on SMF recently. Although that shouldn't make a difference.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 07:07:25 PM
Can you edit TPsubs.template.php on here and change short_subject in the TPortal_recentbox function to subject?
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 07:08:45 PM
Thanks, I don't think I have a clean install of 2.0.18 to test this atm, I will do that soon though now you've mentioned it. ;)

I'll install the 2.0.18 patch on here again now. ;)

Quote from: tino on May 02, 2021, 07:07:25 PM
Can you edit TPsubs.template.php on here and change short_subject in the TPortal_recentbox function to subject?

Yep will give it a go. ;)
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 07:33:00 PM
echo '
<a href="' . $w['href'] . '" title="' . $w['subject'] . '">' . $w['short_subject'] . '</a>
', $txt['by'], ' <b>', $w['poster']['link'],'</b> ';
if (!(TP_SMF21) && ($w['is_new']))


Tino, did you mean change 'short_subject' to just 'subject' or did you actually mean 'subject?'
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 07:38:32 PM
Change the name short_subject to subject

So $w['subject'], there's two instances in there to change I think.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 07:41:04 PM
Quote from: tino on May 02, 2021, 07:38:32 PM
Change the name short_subject to subject

So $w['subject'], there's two instances in there to change I think.

Thanks, yes there is two.  ;)
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 02, 2021, 07:45:28 PM
Quote from: tino on May 02, 2021, 07:38:32 PM
Change the name short_subject to subject

So $w['subject'], there's two instances in there to change I think.

OK, done.  You can see it fixed that issue, but the title is pretty long in the recent block now.  ;)
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 02, 2021, 07:53:23 PM
Quote from: lurkalot on May 02, 2021, 07:45:28 PM
Quote from: tino on May 02, 2021, 07:38:32 PM
Change the name short_subject to subject

So $w['subject'], there's two instances in there to change I think.

OK, done.  You can see it fixed that issue, but the title is pretty long in the recent block now.  ;)

Thought it might, it's a SMF issue then.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: lurkalot on May 03, 2021, 08:48:56 AM
Quote from: tino on May 02, 2021, 07:53:23 PM

Thought it might, it's a SMF issue then.


Thanks Tino. But when you say it's a SMF issue, do you mean it's a bug they have caused in SMF? or just something they have changed and we need to adapt TP for going forward?

Also you said it doesn't seem to happen with a clean install of 2.0.18, so is this something relevant only to the 2.0.18 patch they released?
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: tino on May 03, 2021, 01:23:43 PM
Quote from: lurkalot on May 03, 2021, 08:48:56 AM
Quote from: tino on May 02, 2021, 07:53:23 PM

Thought it might, it's a SMF issue then.


Thanks Tino. But when you say it's a SMF issue, do you mean it's a bug they have caused in SMF? or just something they have changed and we need to adapt TP for going forward?

Also you said it doesn't seem to happen with a clean install of 2.0.18, so is this something relevant only to the 2.0.18 patch they released?

They broke the short_subject string with certain installs with the latest update. TinyPortal just relays that information. My guess would be one of the changes from create_function to an anonymous function is not correct. This will be broken for anything which uses ssi_recentPosts and echos the shortened subject variable.

TinyPortal could get around it by shortening the subject itself, however it's really not an issue on our side.
Title: Re: If this character & is included in the topic title, then on the block of recent.
Post by: @rjen on May 08, 2021, 09:14:23 AM
The cause is found, it is caused by a bug in SMF 2.0.18.
No problem in 2.0.17 and also no problem in SMF2.1

Issue reported at SMF:
https://www.simplemachines.org/community/index.php?topic=577637

The bug also affects the Frontpage topics (if these exceed the maximum number of characters set) and the TPDowloads descriptions on the category pages.

The fix for SMF 2.0.18 is in the Load.php file in the /sources folder:

Find:
'substr' => function($string, $start, $length = null) use ($utf8, $ent_check, $ent_list, $modSettings)
{
$ent_arr = preg_split('~(' . $ent_list . '|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($string), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
return $length === null ? implode('', array_slice($ent_arr, $start)) : implode('', array_slice($ent_arr, $start, $length));
},


Replace by:

'substr' => function($string, $start, $length = null) use ($utf8, $ent_check, $ent_list, $modSettings)
        {
            $ent_arr = preg_split('~(&#' . (empty($modSettings['disableEntityCheck']) ? '\d{1,7}' : '021') . ';|&quot;|&amp;|&lt;|&gt;|&nbsp;|.)~' . ($utf8 ? 'u' : '') . '', $ent_check($string), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
            return $length === null ? implode('', array_slice($ent_arr, $start)) : implode('', array_slice($ent_arr, $start, $length));
        },