Merge pull request #6834 from Chocobo1/cookie

[WebUI] Make cookie parsing robust
This commit is contained in:
Mike Tzou
2017-05-26 23:56:35 +08:00
committed by GitHub
4 changed files with 50 additions and 37 deletions

View File

@@ -30,10 +30,10 @@
#ifndef UTILS_STRING_H
#define UTILS_STRING_H
#include <string>
#include <QString>
class QByteArray;
class QString;
class QLatin1String;
namespace Utils
{
@@ -49,6 +49,19 @@ namespace Utils
bool naturalCompareCaseInsensitive(const QString &left, const QString &right);
QString wildcardToRegex(const QString &pattern);
template <typename T>
T unquote(const T &str, const QString &quotes = QLatin1String("\""))
{
if (str.length() < 2) return str;
for (auto const quote : quotes) {
if (str.startsWith(quote) && str.endsWith(quote))
return str.mid(1, str.length() - 2);
}
return str;
}
}
}