From a359c05b8d84df6acd6e15bf5d70b59e3930f011 Mon Sep 17 00:00:00 2001 From: Noisyfox Date: Sat, 15 Feb 2025 12:31:41 +0800 Subject: [PATCH] FIX:filter the characters of model names in the model mall (#8407) jira:[STUDIO-6649] If the model comes from model mall, the name from the mall will be used when sending and printing. When there are special characters in the name, it will cause the sending to fail. Change-Id: I324441cc7177e7062b79280c5d23afe9eeb5e4c2 (cherry picked from commit 1bcf30c39c648763952703c9060573baa2782f87) Co-authored-by: tao wang --- src/slic3r/GUI/Jobs/PrintJob.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/slic3r/GUI/Jobs/PrintJob.cpp b/src/slic3r/GUI/Jobs/PrintJob.cpp index bb21337e6..5ae4a2dc8 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -269,7 +269,16 @@ void PrintJob::process(Ctl &ctl) auto model_name = model_info->metadata_items.find(BBL_DESIGNER_MODEL_TITLE_TAG); if (model_name != model_info->metadata_items.end()) { try { - params.project_name = model_name->second; + + std::string mall_model_name = model_name->second; + std::replace(mall_model_name.begin(), mall_model_name.end(), ' ', '_'); + const char* unusable_symbols = "<>[]:/\\|?*\" "; + for (const char* symbol = unusable_symbols; *symbol != '\0'; ++symbol) { + std::replace(mall_model_name.begin(), mall_model_name.end(), *symbol, '_'); + } + + std::regex pattern("_+"); + params.project_name = std::regex_replace(mall_model_name, pattern, "_"); } catch (...) {} }