mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-09 13:41:43 +00:00
dmnt.gen2: sanitize brackets in thread names to be valid xml
This commit is contained in:
parent
36bdb83cfc
commit
114d2598da
1 changed files with 26 additions and 1 deletions
|
@ -2353,8 +2353,33 @@ namespace ams::dmnt {
|
|||
m_debug_process.GetThreadName(name, thread_ids[i]);
|
||||
name[sizeof(name) - 1] = '\x00';
|
||||
|
||||
/* Sanitize the thread name. */
|
||||
char sanitized[os::ThreadNameLengthMax * 4 + 1];
|
||||
{
|
||||
char *cur = sanitized;
|
||||
for (size_t i = 0; i < util::size(name); ++i) {
|
||||
if (name[i] == '<') {
|
||||
*(cur++) = '&';
|
||||
*(cur++) = 'l';
|
||||
*(cur++) = 't';
|
||||
*(cur++) = ';';
|
||||
} else if (name[i] == '>') {
|
||||
*(cur++) = '&';
|
||||
*(cur++) = 'r';
|
||||
*(cur++) = 't';
|
||||
*(cur++) = ';';
|
||||
} else {
|
||||
*(cur++) = name[i];
|
||||
}
|
||||
|
||||
if (name[i] == '\x00') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the thread entry */
|
||||
AppendReplyFormat(dst_cur, dst_end, "<thread id=\"p%lx.%lx\" core=\"%u\" name=\"%s\" />", m_process_id.value, thread_ids[i], core, name);
|
||||
AppendReplyFormat(dst_cur, dst_end, "<thread id=\"p%lx.%lx\" core=\"%u\" name=\"%s\" />", m_process_id.value, thread_ids[i], core, sanitized);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue