News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Test fail in 2.0.18 Upgrade

Started by Mike66, March 26, 2021, 12:20:59 PM

Previous topic - Next topic

Mike66

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

Shambles


Mike66

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

Mike66

So the patch needs these lines to be in the script before it can replace them?

Mike66

Just made my way through the script again, I'm lost  :( ..... no idea what to do with this one!

shadav

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....

Shambles

Clicking the pencil icon should demonstrate what the package manager is looking for in your script.js file



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.

Mike66

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.

Shambles

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



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.

Mike66

#9
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

Sir Osis of Liver

If you can pm admin access will have a look.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mike66

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

Sir Osis of Liver

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.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Sir Osis of Liver

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. 
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mike66

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

Illori

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.

Mike66

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.

Mike66

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

Sir Osis of Liver

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.)
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

Mike66

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.

Advertisement: