Simple Machines Community Forum

SMF Development => Bug Reports => Fixed or Bogus Bugs => Topic started by: Bigguy on July 14, 2021, 02:04:51 PM

Title: Error with time zones RC4
Post by: Bigguy on July 14, 2021, 02:04:51 PM
I was playin around with RC4 and tried to put countries in the time zone field. I tried "GB, USA" and "GB USA" (No quotes). It gave me errors and a token verification failure. Please see screenshot.
Title: Re: Error with time zones RC4
Post by: lesmond on July 14, 2021, 02:36:14 PM
I can confirm this, on a fresh install of SMF RC4, the error appears when visiting the profile and  'Features and Options > General'

(https://tinypix.top/i/i8jmw)
Title: Re: Error with time zones RC4
Post by: Sesquipedalian on July 14, 2021, 02:59:32 PM
This is being tracked at https://github.com/SimpleMachines/SMF2.1/issues/6844.

The problem is that "USA" is not a valid two character ISO country code, and SMF currently doesn't check whether the country codes supplied by the admin are valid before it tries to feed them to the timezone_identifiers_list() function. This will be addressed by adding some validation checks on the country codes.

In the meantime, you can avoid this on your forum by using valid two character ISO country codes. The help text for the "Show time zones from these countries first" setting includes a link that will help you look up the correct country codes for the countries you are interested in.
Title: Re: Error with time zones RC4
Post by: Sesquipedalian on July 14, 2021, 03:38:51 PM
A fix has been submitted in https://github.com/SimpleMachines/SMF2.1/pull/6845.
Title: Re: Error with time zones RC4
Post by: lesmond on July 14, 2021, 04:05:19 PM
Thanks @Sesquipedalian
Title: Re: Error with time zones RC4
Post by: Sesquipedalian on July 14, 2021, 04:11:30 PM
No problem. :)
Title: Re: Error with time zones RC4
Post by: Bigguy on July 14, 2021, 05:59:27 PM
Glad to hear it's bein looked at.
Title: Re: Error with time zones RC4
Post by: live627 on July 15, 2021, 06:14:43 AM
Shouldn't the error details be left-aligned?
Title: Re: Error with time zones RC4
Post by: Bigguy on July 15, 2021, 02:55:44 PM
I know there is a fix being implemented on GH for this but I think it is still bugged. This is a partial quote from one of my members:

Quoteyou can't  take the first 2 letters of a 3 letter code. Some countries 2 and 3 letter codes change.
E.G Bangladesh's 2 letter is BD its 3 letter is BGD if you substitute BGD to BG that is Bulgaria.

Is this not going to cause a few bugs ??? He also suggests maybe trying to match up the first and third letter in a three letter country code as that may be more successful. I posted this on GH as well but though I might as well add it here to. I guess I should add that this is using the new code for the fix on GH.
Title: Re: Error with time zones RC4
Post by: Aleksi "Lex" Kilpinen on July 15, 2021, 03:14:06 PM
https://www.iban.com/country-codes
Every country has a 2 letter code.
Title: Re: Error with time zones RC4
Post by: Sesquipedalian on July 15, 2021, 03:30:01 PM
The member on your site misunderstands the purpose of that part of the code, Bigguy. It is not meant to correct three-character codes to two-character codes. It is just removing white space and any extra characters that might have snuck into the input for whatever reason.

If the admin enters "Purple monkeys", it will be truncated and capitalized to "PU". If the admin enters "Viet Nam", it will be truncated and capitalized to "VI". If the admin enters "USA", it will be truncated and capitalized to "US". If the admin enters "BGD", it will be truncated and capitalized to "BG".

Generally speaking, if the truncation happens to produce a valid but unexpected result, it will be the responsibility of the admin to find and enter the correct two-character code for the intended country.

EDIT: ...Actually, now that I think about it, it's probably cleaner to just fail immediately on overlong strings, rather than truncating them. If the admin accidentally enters an extra character, we'll just reject the whole string.
Title: Re: Error with time zones RC4
Post by: Bigguy on July 15, 2021, 05:04:28 PM
That's fine. I just thought I would bring it up as after your code from GH was applied to a RC4 install it got the two mixed up and we thought it was an error. Thanks for explaining and if something good came out  of this, well all the better. :)