csv plugin: only attempt to parse ascii as numbers - closes #2450
This commit is contained in:
parent
9cba3a2036
commit
c53bcd99a6
2 changed files with 7 additions and 4 deletions
|
@ -694,10 +694,7 @@ void csv_datasource::parse_csv(T & stream,
|
|||
desc_.add_descriptor(mapnik::attribute_descriptor(fld_name,mapnik::String));
|
||||
}
|
||||
}
|
||||
else if ((value[0] >= '0' && value[0] <= '9') ||
|
||||
value[0] == '-' ||
|
||||
value[0] == '+' ||
|
||||
value[0] == '.')
|
||||
else if (csv_utils::is_likely_number(value))
|
||||
{
|
||||
bool has_e = value.find("e") != std::string::npos;
|
||||
if (has_dot || has_e)
|
||||
|
|
|
@ -26,9 +26,15 @@
|
|||
|
||||
#include <string>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
namespace csv_utils
|
||||
{
|
||||
static inline bool is_likely_number(std::string const& value)
|
||||
{
|
||||
return( strspn( value.c_str(), "e-.+0123456789" ) == value.size() );
|
||||
}
|
||||
|
||||
static inline void fix_json_quoting(std::string & csv_line)
|
||||
{
|
||||
std::string wrapping_char;
|
||||
|
|
Loading…
Reference in a new issue