Skip to content

Commit d972d5b

Browse files
committed
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
1 parent 6d69ff0 commit d972d5b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/imagewriter.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,25 @@ QString ImageWriter::getSSID()
912912
return ssid;
913913
}
914914

915+
inline QString unescapeXml(QString str)
916+
{
917+
static const char *table[] = {
918+
"&lt;", "<",
919+
"&gt;", ">",
920+
"&quot;", "\"",
921+
"&apos;", "'",
922+
"&amp;", "&"
923+
};
924+
int tableLen = sizeof(table) / sizeof(table[0]);
925+
926+
for (int i=0; i < tableLen; i+=2)
927+
{
928+
str.replace(table[i], table[i+1]);
929+
}
930+
931+
return str;
932+
}
933+
915934
QString ImageWriter::getPSK(const QString &ssid)
916935
{
917936
#ifdef Q_OS_WIN
@@ -956,7 +975,7 @@ QString ImageWriter::getPSK(const QString &ssid)
956975
QRegularExpressionMatch match = rx.match(xml);
957976

958977
if (match.hasMatch()) {
959-
psk = match.captured(1);
978+
psk = unescapeXml(match.captured(1));
960979
}
961980

962981
WlanFreeMemory(xmlstr);

0 commit comments

Comments
 (0)