Fixed Discord embed fail to parse theme-color with rgb() components


Well-known member
Affected version
Previous parse_less_color would render the to #xxyyzz format which Discord would read and use to tint the embed.

As a result of this change; this no longer works.

This sort of regex looks able to extract and convert things as required without requiring a full LESS parser.
if (\preg_match('/^\s*(?:rgb|rgba)\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d{1,3})\s*)?\)\s*$/i', $value, $matches))
    $r = $matches[2];
    $g = $matches[3];
    $b = $matches[4];
    $a = $matches[5] ?? '';

    if ($a === '')
        return \sprintf("#%02x%02x%02x", $r, $g, $b);
        return \sprintf("#%02x%02x%02x%02x", $r, $g, $b, $a);


Well-known member
Derp off 1 by on my regex indexes.

should be;
    $r = $matches[1];
    $g = $matches[2];
    $b = $matches[3];
    $a = $matches[4] ?? '';

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.7).

Change log:
When parsing a color string (such as for the metaThemeColor property usage) normalize the color to its hex value by default.
There may be a delay before changes are rolled out to the XenForo Community.