Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Mike66 on March 26, 2021, 12:20:59 PM

Title: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 12:20:59 PM
Hi folks

I've got a test fail holding me back from a 2.0.17 to 2.0.18 upgrade.

Seems to be a script issue in my site's custom theme, all other tests are passing.

I don't want to lose my custom theme and am not sure how to proceed with trying to find what's wrong with the script? Not been stuck like this before.

Best wishes
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Shambles on March 26, 2021, 12:26:31 PM
Treat it like any other mod that shows failure messages:

https://wiki.simplemachines.org/smf/Error_in_mod_installation
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 12:36:26 PM
Thanks Shambles, I'll try and work out what to do, but must confess that I'm wary of playing with scripts.

The edit icons for (1) and (2) replace gave me the following:

Best wishes
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 01:14:02 PM
So the patch needs these lines to be in the script before it can replace them?
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 01:34:13 PM
Just made my way through the script again, I'm lost  :( ..... no idea what to do with this one!
Title: Re: Test fail in 2.0.18 Upgrade
Post by: shadav on March 26, 2021, 02:59:21 PM
what is it looking for to replace

I can't really tell by the images

look for something similar to what it is searching for

it could just be a difference in spaces

or it could be something else you added changed what it is looking for

or as this seems to be a custom theme, who knows :p what it is looking for may not even be in there....
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Shambles on March 26, 2021, 03:48:48 PM
Clicking the pencil icon should demonstrate what the package manager is looking for in your script.js file

(https://i.imgur.com/y91TEcT.jpg)

The package manager cannot find the text that it says it needs to find, so you need to see if you can find something that looks similar in the script file.

This process isn't about knowing scripts, but knowing how to edit.

Get a copy of Notepad++ as your editor.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 04:12:06 PM
Thanks again Shambles  :)

The two attached screenshots in reply #2 are of what the pencil icon gave me.

The attached script in reply #3 is the theme one that is causing the fail.

I can't work out how/what to change when I open the script and read through it, and I don't want to risk breaking anything by doing it wrong.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Shambles on March 26, 2021, 05:49:47 PM
I think we're at cross purposes here.

When you click the pencil icon you should be shown the exact text of what is being searched for [in the named file] and what the intended edit is meant to be. You may have to scroll the window to see the latter.

EG

(https://i.imgur.com/UpDtYUA.jpg)

No matter whether it's a core SMF file/script, or a theme-specific script [unlikely] the resolution is the same. Find the text that's being searched for (even if it's been slightly modified by a previously installed mod) and see how you can manually apply the edit that's being recommended.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 26, 2021, 06:28:07 PM
Hi Shambles,

Thanks for your patience. That's what I expected to see when I clicked the two pencil icons, but I've checked again, full screen, there are no scroll bars, no 'code find' and no 'code replace'.

The pencil icon for fail (1) simply says:
Quotereturn this;
}
var n, sReturn = '';

// Recode from UTF16 (native .js) to UTF8
for (var i = 0, iTextLen = this.length; i < iTextLen; i++)
{
// Below xFFFF, UTF16 simply = the code points
n = this.charCodeAt(i);
if (n < 128)
sReturn += String.fromCharCode(n);
else if (n < 2048)
sReturn += String.fromCharCode(192 | n >> 6) + String.fromCharCode(128 | n & 63);
// 0xD800 - 0xDBFF
else if (n >= 55296 && n <= 56319)
{
// In this range, this is the beginning of a surrogate pair, where 4-byte utf8 chars are
n = 65536 + ((n & 1023) << 10) + (this.charCodeAt(i + 1) & 1023);
sReturn += String.fromCharCode(240 | n >> 18) + String.fromCharCode(128 | n >> 12 & 63) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
// Skip next char, already used...
i++;
}
else
sReturn += String.fromCharCode(224 | n >> 12) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
}

return sReturn;
}

And for fail (2):
Quoteif (smf_charset == 'UTF-8')
return encodeURIComponent(this);

return escape(this).replace(/\+/g, '%2b').replace('*', '%2a').replace('/', '%2f').replace('@', '%40');
}
return escape(this).replace(/\+/g, '%2b').replace('*', '%2a').replace('/', '%2f').replace('@', '%40');
}

As per the screen shots in reply #2.

Thanks again.
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Sir Osis of Liver on March 26, 2021, 09:43:33 PM
If you can pm admin access will have a look.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 27, 2021, 07:13:41 AM
Quote from: Sir Osis of Liver on March 26, 2021, 09:43:33 PM
If you can pm admin access will have a look.


Thanks, very much appreciated, I have sent you a pm.

Best wishes
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Sir Osis of Liver on March 27, 2021, 11:24:33 PM
Interesting, never seen this before.  As per Mike's posts, package manager is displaying code blocks, nothing else, for two errors in scripts.js in Green_Factory_Theme.  No target code, no replacement code.  Does same in Curve.  Don't recognize the theme, can't find it on theme site.  Patch will install without errors except in this theme.  Something in theme code is borking package manager.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Sir Osis of Liver on March 28, 2021, 12:07:43 AM
This code is 2.0.18 core (minus indents), the two preceding lines are not:



var n, sReturn = '';

// Recode from UTF16 (native .js) to UTF8
for (var i = 0, iTextLen = this.length; i < iTextLen; i++)
{
// Below xFFFF, UTF16 simply = the code points
n = this.charCodeAt(i);
if (n < 128)
sReturn += String.fromCharCode(n);
else if (n < 2048)
sReturn += String.fromCharCode(192 | n >> 6) + String.fromCharCode(128 | n & 63);
// 0xD800 - 0xDBFF
else if (n >= 55296 && n <= 56319)
{
// In this range, this is the beginning of a surrogate pair, where 4-byte utf8 chars are
n = 65536 + ((n & 1023) << 10) + (this.charCodeAt(i + 1) & 1023);
sReturn += String.fromCharCode(240 | n >> 18) + String.fromCharCode(128 | n >> 12 & 63) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
// Skip next char, already used...
i++;
}
else
sReturn += String.fromCharCode(224 | n >> 12) + String.fromCharCode(128 | n >> 6 & 63) + String.fromCharCode(128 | n & 63);
}

return sReturn;
}



This code is also core, but the preceding and duplicate following lines are not:



return escape(this).replace(/\+/g, '%2b').replace('*', '%2a').replace('/', '%2f').replace('@', '%40');
}



No idea why pm is choking on it.  I'd be inclined to backup forum files, install the patch, see if anything breaks. 
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 28, 2021, 04:55:50 AM
Thanks for having a look Sir Osis of Liver, very much appreciated, and nice to know that I'm not losing my marbles.

It is the Factory Theme from SMF Packs with some custom work by SMF Packs. I have made additional changes to improve responsiveness and layout, but these have only been HTML and CSS.

Not sure how I'll proceed, I will put some thought into it. I tend to lean towards 'If it isn't broken, don't fix it' when I encounter a problem, so I might leave it in 2.0.17.

Thanks again!
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Illori on March 28, 2021, 05:15:10 AM
if you leave it at 2.0.17 you may leave yourself open to being hacked. we dont release updates just because we want to usually they include a security patch to keep your forum safe and secure.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 28, 2021, 05:22:01 AM
Agreed, I always do my best to keep everything up to date Illori.

I'm just being a bit cautious with this one, as I've put a lot of hours into getting it to where it is now  ;)

I'm sure I'll bite the bullet and give it a go, once I've mulled it over in my head.
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 28, 2021, 05:37:44 AM
I have installed the patch ..... and so far, nothing appears to be broken.

I'll let things run for a while to see if any issues arise, and then mark the topic resolved.

Thanks again for your help!
Mike
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Sir Osis of Liver on March 28, 2021, 04:38:59 PM
You might want to run this by Nibogo at SMFPacks.  Something in theme code is affecting package manager, he should know about it.  (I see he's still running 2.0.17 on his forum.)
Title: Re: Test fail in 2.0.18 Upgrade
Post by: Mike66 on March 28, 2021, 07:03:44 PM
Quote from: Sir Osis of Liver on March 28, 2021, 04:38:59 PM
You might want to run this by Nibogo at SMFPacks.  Something in theme code is affecting package manager, he should know about it.  (I see he's still running 2.0.17 on his forum.)


Thanks again, I've dropped him a message.