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:
parent
df298c6046
commit
4b77ecbe83
@ -9,6 +9,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "pbd/utf8_utils.h"
|
||||||
#include "pbd/xml++.h"
|
#include "pbd/xml++.h"
|
||||||
|
|
||||||
#include <libxml/debugXML.h>
|
#include <libxml/debugXML.h>
|
||||||
@ -595,15 +596,17 @@ XMLNode::set_property(const char* name, const string& value)
|
|||||||
{
|
{
|
||||||
XMLPropertyIterator iter = _proplist.begin();
|
XMLPropertyIterator iter = _proplist.begin();
|
||||||
|
|
||||||
|
std::string const v = PBD::sanitize_utf8 (value);
|
||||||
|
|
||||||
while (iter != _proplist.end()) {
|
while (iter != _proplist.end()) {
|
||||||
if ((*iter)->name() == name) {
|
if ((*iter)->name() == name) {
|
||||||
(*iter)->set_value (value);
|
(*iter)->set_value (v);
|
||||||
return *iter;
|
return *iter;
|
||||||
}
|
}
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLProperty* new_property = new XMLProperty(name, value);
|
XMLProperty* new_property = new XMLProperty(name, v);
|
||||||
|
|
||||||
if (!new_property) {
|
if (!new_property) {
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user