mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-18 06:28:03 -06:00
Fix handling of tags containing '&' character
PR #21024. Closes #20773.
This commit is contained in:
committed by
GitHub
parent
b52fa98a02
commit
ccdf178ee7
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Bittorrent Client using Qt and libtorrent.
|
||||
* Copyright (C) 2024 Vladimir Golovnev <glassez@yandex.ru>
|
||||
* Copyright (C) 2017 Mike Tzou
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -54,6 +55,7 @@
|
||||
|
||||
#include "base/global.h"
|
||||
#include "base/path.h"
|
||||
#include "base/tag.h"
|
||||
#include "base/utils/fs.h"
|
||||
#include "base/utils/version.h"
|
||||
|
||||
@@ -216,3 +218,29 @@ void Utils::Gui::openFolderSelect(const Path &path)
|
||||
openPath(path.parentPath());
|
||||
#endif
|
||||
}
|
||||
|
||||
QString Utils::Gui::tagToWidgetText(const Tag &tag)
|
||||
{
|
||||
return tag.toString().replace(u'&', u"&&"_s);
|
||||
}
|
||||
|
||||
Tag Utils::Gui::widgetTextToTag(const QString &text)
|
||||
{
|
||||
// replace pairs of '&' with single '&' and remove non-paired occurrences of '&'
|
||||
QString cleanedText;
|
||||
cleanedText.reserve(text.size());
|
||||
bool amp = false;
|
||||
for (const QChar c : text)
|
||||
{
|
||||
if (c == u'&')
|
||||
{
|
||||
amp = !amp;
|
||||
if (amp)
|
||||
continue;
|
||||
}
|
||||
|
||||
cleanedText.append(c);
|
||||
}
|
||||
|
||||
return Tag(cleanedText);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user