From 1bcf30c39c648763952703c9060573baa2782f87 Mon Sep 17 00:00:00 2001 From: tao wang Date: Tue, 30 Apr 2024 10:49:31 +0800 Subject: [PATCH] FIX:filter the characters of model names in the model mall 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 --- 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 e347e5ad6..d3b642bd7 100644 --- a/src/slic3r/GUI/Jobs/PrintJob.cpp +++ b/src/slic3r/GUI/Jobs/PrintJob.cpp @@ -280,7 +280,16 @@ void PrintJob::process() 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 (...) {} }