diff --git a/src/libslic3r/Format/bbs_3mf.cpp b/src/libslic3r/Format/bbs_3mf.cpp index be32d06155..f46a0b087e 100644 --- a/src/libslic3r/Format/bbs_3mf.cpp +++ b/src/libslic3r/Format/bbs_3mf.cpp @@ -2757,31 +2757,31 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result) check_painting_version(m_mm_painting_version, MM_PAINTING_VERSION, _(L("The selected 3MF contains multi-material painted object using a newer version of BambuStudio and is not compatible.")));*/ } else if (m_curr_metadata_name == BBL_MODEL_ID_TAG) { - m_model_id = m_curr_characters; + m_model_id = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_MODEL_NAME_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found model name = " << m_curr_characters; - model_info.model_name = m_curr_characters; + model_info.model_name = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_DESIGNER_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found designer = " << m_curr_characters; - m_designer = m_curr_characters; + m_designer = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_DESIGNER_USER_ID_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found designer_user_id = " << m_curr_characters; - m_designer_user_id = m_curr_characters; + m_designer_user_id = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_DESIGNER_COVER_FILE_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found designer_cover = " << m_curr_characters; - model_info.cover_file = m_curr_characters; + model_info.cover_file = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_DESCRIPTION_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found description = " << m_curr_characters; - model_info.description = m_curr_characters; + model_info.description = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_LICENSE_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found license = " << m_curr_characters; - model_info.license = m_curr_characters; + model_info.license = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_COPYRIGHT_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found copyright = " << m_curr_characters; - model_info.copyright = m_curr_characters; + model_info.copyright = xml_unescape(m_curr_characters); } else if (m_curr_metadata_name == BBL_REGION_TAG) { BOOST_LOG_TRIVIAL(trace) << "design_info, load_3mf found region = " << m_curr_characters; - m_contry_code = m_curr_characters; + m_contry_code = xml_unescape(m_curr_characters); } return true; @@ -4363,6 +4363,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result) return false; } + { std::stringstream stream; reset_stream(stream); @@ -4413,27 +4414,29 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result) model_id = project->project_model_id; region_code = project->project_country_code; } + if (!sub_model) { + stream << " <" << METADATA_TAG << " name=\"" << BBL_MODEL_NAME_TAG << "\">" << xml_escape(name) << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_TAG << "\">" << xml_escape(user_name) << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_USER_ID_TAG << "\">" << user_id << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_COVER_FILE_TAG << "\">" << xml_escape(design_cover) << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_DESCRIPTION_TAG << "\">" << xml_escape(description) << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_COPYRIGHT_TAG << "\">" << xml_escape(copyright) << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_LICENSE_TAG << "\">" << xml_escape(license) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_MODEL_NAME_TAG << "\">" << xml_escape(name) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_TAG << "\">" << xml_escape(user_name) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_USER_ID_TAG << "\">" << user_id << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_DESIGNER_COVER_FILE_TAG << "\">" << xml_escape(design_cover) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_DESCRIPTION_TAG << "\">" << xml_escape(description) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_COPYRIGHT_TAG << "\">" << xml_escape(copyright) << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_LICENSE_TAG << "\">" << xml_escape(license) << "\n"; + /* save model info */ + if (!model_id.empty()) { + stream << " <" << METADATA_TAG << " name=\"" << BBL_MODEL_ID_TAG << "\">" << model_id << "\n"; + stream << " <" << METADATA_TAG << " name=\"" << BBL_REGION_TAG << "\">" << region_code << "\n"; + } - /* save model info */ - if (!model_id.empty()) { - stream << " <" << METADATA_TAG << " name=\"" << BBL_MODEL_ID_TAG << "\">" << model_id << "\n"; - stream << " <" << METADATA_TAG << " name=\"" << BBL_REGION_TAG << "\">" << region_code << "\n"; + std::string date = Slic3r::Utils::utc_timestamp(Slic3r::Utils::get_current_time_utc()); + // keep only the date part of the string + date = date.substr(0, 10); + stream << " <" << METADATA_TAG << " name=\"CreationDate\">" << date << "\n"; + stream << " <" << METADATA_TAG << " name=\"ModificationDate\">" << date << "\n"; + stream << " <" << METADATA_TAG << " name=\"Application\">" << SLIC3R_APP_KEY << "-" << SLIC3R_VERSION << "\n"; } - std::string date = Slic3r::Utils::utc_timestamp(Slic3r::Utils::get_current_time_utc()); - // keep only the date part of the string - date = date.substr(0, 10); - stream << " <" << METADATA_TAG << " name=\"CreationDate\">" << date << "\n"; - stream << " <" << METADATA_TAG << " name=\"ModificationDate\">" << date << "\n"; - stream << " <" << METADATA_TAG << " name=\"Application\">" << SLIC3R_APP_KEY << "-" << SLIC3R_VERSION << "\n"; stream << " <" << RESOURCES_TAG << ">\n"; std::string buf = stream.str(); if (! buf.empty() && ! mz_zip_writer_add_staged_data(&context, buf.data(), buf.size())) { diff --git a/src/libslic3r/Utils.hpp b/src/libslic3r/Utils.hpp index 485cd0a05a..44281c5920 100644 --- a/src/libslic3r/Utils.hpp +++ b/src/libslic3r/Utils.hpp @@ -283,6 +283,7 @@ inline typename CONTAINER_TYPE::value_type& next_value_modulo(typename CONTAINER } extern std::string xml_escape(std::string text, bool is_marked = false); +extern std::string xml_unescape(std::string text); #if defined __GNUC__ && __GNUC__ < 5 && !defined __clang__ diff --git a/src/libslic3r/utils.cpp b/src/libslic3r/utils.cpp index 67b873cc46..731848ed55 100644 --- a/src/libslic3r/utils.cpp +++ b/src/libslic3r/utils.cpp @@ -1182,6 +1182,42 @@ std::string xml_escape(std::string text, bool is_marked/* = false*/) return text; } +std::string xml_unescape(std::string s) +{ + std::string ret; + std::string::size_type i = 0; + std::string::size_type pos = 0; + while (i < s.size()) { + std::string rep; + if (s[i] == '&') { + if (s.substr(i, 4) == "<") { + ret += s.substr(pos, i - pos) + "<"; + i += 4; + pos = i; + } + else if (s.substr(i, 4) == ">") { + ret += s.substr(pos, i - pos) + ">"; + i += 4; + pos = i; + } + else if (s.substr(i, 5) == "&") { + ret += s.substr(pos, i - pos) + "&"; + i += 5; + pos = i; + } + else { + ++i; + } + } + else { + ++i; + } + } + + ret += s.substr(pos); + return ret; +} + std::string format_memsize_MB(size_t n) { std::string out; diff --git a/src/slic3r/GUI/Auxiliary.cpp b/src/slic3r/GUI/Auxiliary.cpp index 73d5baa94b..c3ea3d703e 100644 --- a/src/slic3r/GUI/Auxiliary.cpp +++ b/src/slic3r/GUI/Auxiliary.cpp @@ -364,7 +364,7 @@ void AuFile::on_set_cover() { if (wxGetApp().plater()->model().model_info == nullptr) { wxGetApp().plater()->model().model_info = std::make_shared(); } - wxGetApp().plater()->model().model_info->cover_file = m_file_name.ToStdString(); + wxGetApp().plater()->model().model_info->cover_file = std::string(m_file_name.ToUTF8().data()); auto full_path = m_file_path.branch_path(); auto full_root_path = full_path.branch_path();