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 <tao.wang@bambulab.com>
This commit is contained in:
Noisyfox 2025-02-15 12:31:41 +08:00 committed by GitHub
parent 2e4a2a26e6
commit a359c05b8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 (...) {}
}