stricter string2bool conversion - refs #2348
This commit is contained in:
parent
3715217b2d
commit
04e4b47d91
1 changed files with 7 additions and 3 deletions
|
@ -41,7 +41,9 @@ by many other headers inside mapnik.
|
|||
|
||||
MAPNIK_DECL inline bool string2bool(std::string const& value, bool & result)
|
||||
{
|
||||
if (value == "true") {
|
||||
if (value.empty() || value.size() > 5) {
|
||||
return false;
|
||||
} else if (value == "true") {
|
||||
return result = true;
|
||||
} else if (value == "false") {
|
||||
result = false;
|
||||
|
@ -51,9 +53,11 @@ MAPNIK_DECL inline bool string2bool(std::string const& value, bool & result)
|
|||
std::transform(val.begin(), val.end(), val.begin(), ::tolower);
|
||||
if (val == "true" || val == "yes" || val == "1" || val == "on") {
|
||||
return result = true;
|
||||
} else if (val == "false" || val == "no" || val == "0" || val == "off") {
|
||||
result = false;
|
||||
return true;
|
||||
}
|
||||
result = false;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
MAPNIK_DECL inline bool string2bool(const char * iter, const char * end, bool & result)
|
||||
|
|
Loading…
Add table
Reference in a new issue