Merge branch 'master' of https://github.com/prusa3d/Slic3r into opengl_to_cpp
This commit is contained in:
commit
43784f3409
1 changed files with 28 additions and 1 deletions
|
@ -674,6 +674,33 @@ bool load_amf(const char *path, PresetBundle* bundle, Model *model)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string xml_escape(std::string text)
|
||||||
|
{
|
||||||
|
std::string::size_type pos = 0;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
pos = text.find_first_of("\"\'&<>", pos);
|
||||||
|
if (pos == std::string::npos)
|
||||||
|
break;
|
||||||
|
|
||||||
|
std::string replacement;
|
||||||
|
switch (text[pos])
|
||||||
|
{
|
||||||
|
case '\"': replacement = """; break;
|
||||||
|
case '\'': replacement = "'"; break;
|
||||||
|
case '&': replacement = "&"; break;
|
||||||
|
case '<': replacement = "<"; break;
|
||||||
|
case '>': replacement = ">"; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
text.replace(pos, 1, replacement);
|
||||||
|
pos += replacement.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
bool store_amf(const char *path, Model *model, Print* print, bool export_print_config)
|
bool store_amf(const char *path, Model *model, Print* print, bool export_print_config)
|
||||||
{
|
{
|
||||||
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
if ((path == nullptr) || (model == nullptr) || (print == nullptr))
|
||||||
|
@ -701,7 +728,7 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
|
||||||
{
|
{
|
||||||
std::string config = "\n";
|
std::string config = "\n";
|
||||||
GCode::append_full_config(*print, config);
|
GCode::append_full_config(*print, config);
|
||||||
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << config << "</metadata>\n";
|
stream << "<metadata type=\"" << SLIC3R_CONFIG_TYPE << "\">" << xml_escape(config) << "</metadata>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &material : model->materials) {
|
for (const auto &material : model->materials) {
|
||||||
|
|
Loading…
Reference in a new issue