FIX:Remove all spaces and special symbols in the plate name

Remove all spaces and special symbols like \ / : * ? " < > |  in the plate name,allow xml special symbols such as & '

Change-Id: I2b391d13be709af0e47f1573c0e225e63591fd23
(cherry picked from commit 135c97e9916c852a8625d9d9bf0a4dda051b6e2b)
This commit is contained in:
zhou.xu 2023-05-23 10:29:32 +08:00 committed by Lane.Wei
parent 531757366e
commit b849a82725
2 changed files with 11 additions and 8 deletions

View file

@ -3838,7 +3838,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
m_curr_plater->plate_index = atoi(value.c_str());
}
else if (key == PLATER_NAME_ATTR) {
m_curr_plater->plate_name = encode_path(value.c_str());
m_curr_plater->plate_name = xml_unescape(encode_path(value.c_str()));
}
else if (key == LOCK_ATTR)
{
@ -6996,7 +6996,7 @@ void PlateData::parse_filament_info(GCodeProcessorResult *result)
stream << " <" << PLATE_TAG << ">\n";
//plate index
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATERID_ATTR << "\" " << VALUE_ATTR << "=\"" << plate_data->plate_index + 1 << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATER_NAME_ATTR << "\" " << VALUE_ATTR << "=\"" << decode_path(plate_data->plate_name.c_str()) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << PLATER_NAME_ATTR << "\" " << VALUE_ATTR << "=\"" << xml_escape(decode_path(plate_data->plate_name.c_str())) << "\"/>\n";
stream << " <" << METADATA_TAG << " " << KEY_ATTR << "=\"" << LOCK_ATTR << "\" " << VALUE_ATTR << "=\"" << std::boolalpha<< plate_data->locked<< "\"/>\n";
ConfigOption* bed_type_opt = plate_data->config.option("curr_bed_type");
t_config_enum_names bed_type_names = ConfigOptionEnum<BedType>::get_enum_names();

View file

@ -1,5 +1,6 @@
#include <cstddef>
#include <algorithm>
#include <regex>
#include <numeric>
#include <vector>
#include <string>
@ -1600,18 +1601,20 @@ void PartPlate::set_plate_name(const std::string &name)
{
// compare if name equal to m_name, case sensitive
if (boost::equals(m_name, name)) return;
m_name = name;
m_name.erase(remove_if(m_name.begin(), m_name.end(), ::isspace), m_name.end());
std::regex reg("[\\\\/:*?\"<>|]");
m_name= regex_replace(m_name, reg, "");
m_name_change = true;
if (m_plater) {
ObjectList *obj_list = wxGetApp().obj_list();
if (obj_list) {
obj_list->GetModel()->SetCurSelectedPlateFullNmae(m_plate_index, name);
obj_list->GetModel()->SetCurSelectedPlateFullNmae(m_plate_index, m_name);
}
}
m_name = name;
m_name_change = true;
if (m_print != nullptr)
m_print->set_plate_name(name);
if (m_print != nullptr)
m_print->set_plate_name(m_name);
}
//get the print's object, result and index