mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[PublicDecks] Escape remote-crafted text in tooltips and the tab title
Deck names and usernames come from other users' records and Qt renders QLabel tooltips as AutoText, so a name like '<h1><table>...' parsed as markup. Escape and bound the deck-name tooltip and escape the username interpolated into the title label.
This commit is contained in:
parent
39178f91c8
commit
f1a827e70f
2 changed files with 7 additions and 3 deletions
|
|
@ -33,7 +33,7 @@ TabPublicDecks::TabPublicDecks(TabSupervisor *_tabSupervisor, AbstractClient *_c
|
|||
model = new RemotePublicDecksModel(client, this);
|
||||
cardSize = SettingsCache::instance().cardsDisplay().getVisualDeckStorageCardSize();
|
||||
|
||||
titleLabel = new QLabel(tr("Public decks of %1").arg(userName), this);
|
||||
titleLabel = new QLabel(tr("Public decks of %1").arg(userName.toHtmlEscaped()), this);
|
||||
QFont titleFont = titleLabel->font();
|
||||
titleFont.setBold(true);
|
||||
titleLabel->setFont(titleFont);
|
||||
|
|
@ -116,7 +116,8 @@ QString TabPublicDecks::getTabText() const
|
|||
|
||||
void TabPublicDecks::retranslateUi()
|
||||
{
|
||||
titleLabel->setText(tr("Public decks of %1").arg(userName));
|
||||
// The username is another user's data, so escape it for the AutoText QLabel.
|
||||
titleLabel->setText(tr("Public decks of %1").arg(userName.toHtmlEscaped()));
|
||||
emptyLabel->setText(tr("This user has not published any decks."));
|
||||
refreshButton->setToolTip(tr("Refresh"));
|
||||
quickSettingsWidget->setToolTip(tr("Public Decks Settings"));
|
||||
|
|
|
|||
|
|
@ -96,7 +96,10 @@ void PublicDeckPreviewWidget::setEntry(const RemotePublicDecksModel::DeckEntry &
|
|||
|
||||
// The deck name is the overlay text on the banner, like the local preview.
|
||||
bannerCardDisplayWidget->setOverlayText(entry.name);
|
||||
setToolTip(entry.name);
|
||||
// The deck name comes from another user's record, and Qt tooltips are
|
||||
// rendered as AutoText, so escape and bound it to keep it readable text
|
||||
// (the overlay painted onto the banner is already a plain painter draw).
|
||||
setToolTip(entry.name.left(200).toHtmlEscaped());
|
||||
setBaseAccessibleName(entry.name);
|
||||
|
||||
tagsFlowWidget->clearLayout();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue