Skip to content

Commit

Permalink
Use case-insensitive lookup to parse colors. (sass#2463)
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile authored and xzyfer committed Aug 16, 2017
1 parent ee05b70 commit b6bc02e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/color_maps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,16 +607,20 @@ namespace Sass {

Color_Ptr_Const name_to_color(const char* key)
{
auto p = names_to_colors.find(key);
if (p != names_to_colors.end()) {
return p->second;
}
return 0;
return name_to_color(std::string(key));
}

Color_Ptr_Const name_to_color(const std::string& key)
{
return name_to_color(key.c_str());
// case insensitive lookup. See #2462
std::string lower{key};
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);

auto p = names_to_colors.find(lower.c_str());
if (p != names_to_colors.end()) {
return p->second;
}
return 0;
}

const char* color_to_name(const int key)
Expand Down

0 comments on commit b6bc02e

Please sign in to comment.