diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index d2ca7b1104..cd94eeaa07 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -706,12 +706,20 @@ namespace Slic3r { m_name = boost::filesystem::path(filename).stem().string(); // we first loop the entries to read from the archive the .model file only, in order to extract the version from it + bool found_model = false; for (mz_uint i = 0; i < num_entries; ++i) { if (mz_zip_reader_file_stat(&archive, i, &stat)) { std::string name(stat.m_filename); std::replace(name.begin(), name.end(), '\\', '/'); - if (boost::algorithm::istarts_with(name, MODEL_FOLDER) && boost::algorithm::iends_with(name, MODEL_EXTENSION)) { + if (boost::algorithm::iends_with(name, MODEL_EXTENSION)) { + if(found_model){ + close_zip_reader(&archive); + add_error("3mf contain multiple .model files and it is not supported yet."); + return false; + } + found_model = true; + try { // valid model name -> extract model @@ -730,6 +738,11 @@ namespace Slic3r { } } } + if (!found_model) { + close_zip_reader(&archive); + add_error("Not valid 3mf. There is missing .model file."); + return false; + } // we then loop again the entries to read other files stored in the archive for (mz_uint i = 0; i < num_entries; ++i) {