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
This commit is contained in:
tao wang 2024-04-30 10:49:31 +08:00 committed by Lane.Wei
parent 9af43a2dfb
commit 1bcf30c39c

View File

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