Skip to content

Commit b6bc02e

Browse files
asottilexzyfer
authored andcommitted
Use case-insensitive lookup to parse colors. (#2463)
Fixes #2462 Spec sass/sass-spec#1161
1 parent ee05b70 commit b6bc02e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/color_maps.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -607,16 +607,20 @@ namespace Sass {
607607

608608
Color_Ptr_Const name_to_color(const char* key)
609609
{
610-
auto p = names_to_colors.find(key);
611-
if (p != names_to_colors.end()) {
612-
return p->second;
613-
}
614-
return 0;
610+
return name_to_color(std::string(key));
615611
}
616612

617613
Color_Ptr_Const name_to_color(const std::string& key)
618614
{
619-
return name_to_color(key.c_str());
615+
// case insensitive lookup. See #2462
616+
std::string lower{key};
617+
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
618+
619+
auto p = names_to_colors.find(lower.c_str());
620+
if (p != names_to_colors.end()) {
621+
return p->second;
622+
}
623+
return 0;
620624
}
621625

622626
const char* color_to_name(const int key)

0 commit comments

Comments
 (0)