Escape HTML command in window caption before passing to QML

Escaping is performed in the model instead of the UI as each of the QML
files needed to be fixed and it is likeley that the issue would come up
again. In the model it's hopefully fixed for good.

BUG: 309960
FIXED-IN: 4.9.4
REVIEW: 107431
icc-effect-5.14.5
Martin Gräßlin 2012-11-23 08:23:34 +01:00
parent 3183b98012
commit 6f90843365
1 changed files with 9 additions and 2 deletions

View File

@ -24,6 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "tabboxconfig.h"
#include "tabboxhandler.h"
// Qt
// TODO: remove with Qt 5, only for HTML escaping the caption
#include <QTextDocument>
#include <QTextStream>
// KDE
#include <KLocale>
@ -69,8 +71,13 @@ QVariant ClientModel::data(const QModelIndex& index, int role) const
}
switch(role) {
case Qt::DisplayRole:
case CaptionRole:
return client->caption();
case CaptionRole: {
QString caption = client->caption();
if (Qt::mightBeRichText(caption)) {
caption = Qt::escape(caption);
}
return caption;
}
case ClientRole:
return qVariantFromValue((void*)client.data());
case DesktopNameRole: {