Windows WLAN PSK retrieval: unescape XML

Assuming unescaping standard XML entities is sufficient.
(Skipping numerical unicode XML entities for now, as
there is not a proper standardized way to
represent non-ascii characters in a PSK anyway)

Ref #541
This commit is contained in:
Floris Bos 2023-01-25 14:02:03 +01:00
parent 6d69ff0797
commit d972d5b87b

View file

@ -912,6 +912,25 @@ QString ImageWriter::getSSID()
return ssid;
}
inline QString unescapeXml(QString str)
{
static const char *table[] = {
"&lt;", "<",
"&gt;", ">",
"&quot;", "\"",
"&apos;", "'",
"&amp;", "&"
};
int tableLen = sizeof(table) / sizeof(table[0]);
for (int i=0; i < tableLen; i+=2)
{
str.replace(table[i], table[i+1]);
}
return str;
}
QString ImageWriter::getPSK(const QString &ssid)
{
#ifdef Q_OS_WIN
@ -956,7 +975,7 @@ QString ImageWriter::getPSK(const QString &ssid)
QRegularExpressionMatch match = rx.match(xml);
if (match.hasMatch()) {
psk = match.captured(1);
psk = unescapeXml(match.captured(1));
}
WlanFreeMemory(xmlstr);