Sanitize XML values to be valid UTF-8 (#9317)

This prevents any non UTF-8 strings to leak into
Ardour XML files, which can make the session unloadable.
This commit is contained in:
Robin Gareus 2023-04-26 17:29:02 +02:00
parent df298c6046
commit 4b77ecbe83
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 5 additions and 2 deletions

View File

@ -9,6 +9,7 @@
#include <string.h>
#include <iostream>
#include "pbd/utf8_utils.h"
#include "pbd/xml++.h"
#include <libxml/debugXML.h>
@ -595,15 +596,17 @@ XMLNode::set_property(const char* name, const string& value)
{
XMLPropertyIterator iter = _proplist.begin();
std::string const v = PBD::sanitize_utf8 (value);
while (iter != _proplist.end()) {
if ((*iter)->name() == name) {
(*iter)->set_value (value);
(*iter)->set_value (v);
return *iter;
}
++iter;
}
XMLProperty* new_property = new XMLProperty(name, value);
XMLProperty* new_property = new XMLProperty(name, v);
if (!new_property) {
return 0;