Add a function that scrubs URL queries from strings.
In some cases, URL queries contain auth information. For cases where error strings are passed from other libraries, such as from gstreamer, add a utility function, ScrubUrlQueries, to strip queries from URLs in strings.
This commit is contained in:
parent
a0bb8ab3a1
commit
5dd6d6725a
|
@ -760,6 +760,13 @@ QByteArray GetUriForGstreamer(const QUrl& url) {
|
|||
return url.toEncoded();
|
||||
}
|
||||
|
||||
QString ScrubUrlQueries(const QString& str) {
|
||||
// If the URL isn't followed by whitespace, this will eat extra characters.
|
||||
QRegExp rx("((?:http|https)://\\S*\\?)\\S*");
|
||||
// QString::replace is non const, so operate on a copy.
|
||||
return QString(str).replace(rx, "\\1 (query removed)");
|
||||
}
|
||||
|
||||
} // namespace Utilities
|
||||
|
||||
ScopedWCharArray::ScopedWCharArray(const QString& str)
|
||||
|
|
|
@ -164,6 +164,9 @@ int GetThreadId();
|
|||
bool IsLaptop();
|
||||
|
||||
QString SystemLanguageName();
|
||||
|
||||
// Scrub messages for to remove queries, which may include auth info, from URLs.
|
||||
QString ScrubUrlQueries(const QString& str);
|
||||
} // namespace Utilities
|
||||
|
||||
class ScopedWCharArray {
|
||||
|
|
Loading…
Reference in New Issue