Menu

#55 Wrong checking of file extension in /vcglib/wrap/io_trimesh/import.h and export.h

v1.0_(example)
closed
nobody
1
2016-02-24
2016-02-23
No

Wrong checking of 3d file extension. If a STL file has extension in .stl, .STL, .Stl, etc in different cases, then the existing function fails in checking.

This piece of code is present in /vcglib/wrap/io_trimesh/import.h and /vcglib/wrap/io_trimesh/export.h

Existing code
.--------------------------
static bool FileExtension(std::string filename, std::string extension)
{
std::locale loc1 ;
std::use_facet<std::ctype\<char> > ( loc1 ).tolower(&filename.begin(),&filename.rbegin());
std::use_facet<std::ctype\<char> > ( loc1 ).tolower(&extension.begin(),&extension.rbegin());
std::string end=filename.substr(filename.length()-extension.length(),extension.length());
return end==extension;
}</std::ctype\<char></std::ctype\<char>

Updated Code
.-----------------------------

static bool FileExtension(std::string filename, std::string extension)
{
std::transform(filename.begin(), filename.end(), filename.begin(), ::tolower);
std::transform(extension.begin(), extension.end(), extension.begin(), ::tolower);
std::string end=filename.substr(filename.length()-extension.length(),extension.length());
return end==extension;
}

Please add this code in the next release.

Thanks,
Sarbeswar

Discussion

  • Paolo Cignoni

    Paolo Cignoni - 2016-02-24

    Done. Thanks for the suggestion!

    p.

     
  • Paolo Cignoni

    Paolo Cignoni - 2016-02-24
    • status: open --> closed
     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB