diff --git a/xs/src/libslic3r/Format/AMF.cpp b/xs/src/libslic3r/Format/AMF.cpp
index 21d4b4d3b..be513166e 100644
--- a/xs/src/libslic3r/Format/AMF.cpp
+++ b/xs/src/libslic3r/Format/AMF.cpp
@@ -761,7 +761,7 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
for (const std::string &key : object->config.keys())
stream << " " << object->config.serialize(key) << "\n";
if (!object->name.empty())
- stream << " " << object->name << "\n";
+ stream << " " << xml_escape(object->name) << "\n";
std::vector layer_height_profile = object->layer_height_profile_valid ? object->layer_height_profile : std::vector();
if (layer_height_profile.size() >= 4 && (layer_height_profile.size() % 2) == 0) {
// Store the layer height profile as a single semicolon separated list.
@@ -805,7 +805,7 @@ bool store_amf(const char *path, Model *model, Print* print, bool export_print_c
for (const std::string &key : volume->config.keys())
stream << " " << volume->config.serialize(key) << "\n";
if (!volume->name.empty())
- stream << " " << volume->name << "\n";
+ stream << " " << xml_escape(volume->name) << "\n";
if (volume->modifier)
stream << " 1\n";
for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++i) {