MyBB Community Forums

Full Version: Accented char in mybb_theme_colors.xml breaks default theme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

From years now, I translate mybb into french (installation included).

Since v1.8.0 a new functionnality was implemented : colors templates for default theme with the file /install/resources/mybb_themes_color.xml.
I translated the color themes names into french. So "Crepuscule" became "Crépucule". That file was created on february 2015 and never changed nor problematic.

But, since v1.8.16, this file causes an issue.
When editing theme settings, now I get the error "$l['error_invalid_color']" defined in /admin/styles.lang.php, so I was unable to save anything.

Comparing "/admin/modules/style/themes.php" between 1.8.15 and 1.8.16, I see you restrict the stylesheets names to only alphanumeric characters in v1.8.16 and later!
Lines 1095 to 1107.
foreach($colors as $color)
     {
    $color = trim($color);
    if(preg_match('/^[a-z0-9]+={1}[a-z0-9]+$/i', $color))
     {
           $color = explode("=", $color);
           $properties['colors'][$color[0]] = $color[1];
    }
    else
    {
          $errors[] = $lang->sprintf($lang->error_invalid_color, $color);
    }
   }

So, now it's impossible made any changes in default theme. That'a pity!
If I change mybb_theme_colors.xml with new one without accented char, the error remains.
Rebuilding default_theme cache does not correct anything.

I tried to change 'é' to 'e' in database (mybb_themes and mybb_datacache), but doing this breaks completely the default theme ! The CSS are lost and now the error is :

Warning [2] Invalid argument supplied for foreach() - Line: 1361
File: ...\admin\modules\style\themes.php PHP 5.6.12 (WINNT)
File     Line     Function
D:\xampp\htdocs\mybb_test\admin\modules\style\themes.php     1361     errorHandler->error
D:\xampp\htdocs\mybb_test\admin\index.php     821     require!

I can't understand why you changed this! Why a stylesheet name should not have accented chars?... I don't know who had the idea to change suddenly this behaviour, but my question is :
How can I correct this on a running mybb >= 1.8.6 ?
I need to inform my members on how to correct without loosing all.

Note : I wrote a little script (see attachment) inspired from install index.php to re-execute the function insert_templates(). After uploaded the file in /install directory et replaced mybb_theme_colors.xml file, it seems working, but are there a best and/or light way to restore default theme functionnality after replaced mybb_theme_colors.xml file?

Thanks for answer.
[attachment=40848]
More than 100 views and no response! Huh
Many views are by bots, so the view count shouldn't be taken as read.

This change was made in Pull Request #3218 to fix a reported issue (#2094) (original thread).

The change does look like it would cause problems for existing colours - perhaps it should try to convert those names or something to replace some special characters with similar ASCII versions (eg: 'é' to 'e'). I'm not sure what the best approach would be, but I've nudged effone who wrote the patch so we can discuss it.
Thanks for answer!

Did you understand that this "preg_match()" breaks the default theme that becomes completely unusable !? Even changing 'é' by 'e' in both mybb_theme_colors.xml file the database solves nothing!
That's why I attached a script because it's necessary to reinstall the default theme.

Many countries use unicode characters!

I think our members never use the default theme otherwise the bug would be reported since a long time.
I think this regular expression to limit the name of the theme is perfectly useless and problematic.

Regards.

Edit : In other words, you resolved a "smart bug" creating a new big one! Huh (for those who customized/localized installation files)
I have to say that your developers/coders must make a difference between "reserved" characters and "foreign" characters...

Unless you do not care about international users and translators...
Hi,

Thank you for your report. We have pushed this issue to our Github repository for further analysis where you can track our commits and progress with fixing this bug. Discussions regarding this bug may also take place there too.

Follow this link to visit the issue on Github: https://github.com/mybb/mybb/issues/3456

Thanks for contributing to MyBB!

Regards,
The MyBB Group
(2018-09-27, 11:30 AM)exdiogene Wrote: [ -> ]I have to say that your developers/coders must make a difference between "reserved" characters and "foreign" characters...

Unless you do not care about international users and translators...

It was discussed and decided to place a validation for color naming for good reasons. Please go through the discussions / suggestions in the reporting thread:
https://community.mybb.com/thread-170598.html