mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-28 00:42:19 -07:00
[Chat] Fix percent-encoding and scheme gating in game-link chat labels
Game descriptions containing '%' were rendered as '%25' in the chat button label because QUrlQuery's default decode leaves %25 untouched. Use QUrl::FullyDecoded for the description item, and restrict the invite-button treatment to cockatrice://joingame links; any other cockatrice:// scheme now falls through to plain text.
This commit is contained in:
parent
2076ac734d
commit
0fb4f4fa53
1 changed files with 11 additions and 4 deletions
|
|
@ -226,7 +226,9 @@ void ChatView::appendGameLinkTag(QTextCursor &cursor, const QString &url)
|
|||
const QUrl gameUrl(url);
|
||||
const QUrlQuery query(gameUrl);
|
||||
const QString hostname = query.queryItemValue("hostname");
|
||||
const QString description = query.queryItemValue("game");
|
||||
// FullyDecoded undoes every %XX escape, so a description that itself
|
||||
// contains "%" cannot end up displayed as "%25" in the label.
|
||||
const QString description = query.queryItemValue("game", QUrl::FullyDecoded);
|
||||
const int gameId = query.queryItemValue("gameid").toInt();
|
||||
|
||||
QString label;
|
||||
|
|
@ -544,9 +546,14 @@ void ChatView::checkWord(QTextCursor &cursor, QString &message)
|
|||
}
|
||||
|
||||
if (fullWordUpToSpaceOrEnd.startsWith("cockatrice://", Qt::CaseInsensitive)) {
|
||||
appendGameLinkTag(cursor, fullWordUpToSpaceOrEnd);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
return;
|
||||
// Only links to a game (cockatrice://joingame) become invite buttons;
|
||||
// any other cockatrice:// scheme falls through to plain text below.
|
||||
const QUrl gameLink(fullWordUpToSpaceOrEnd);
|
||||
if (gameLink.host().compare("joingame", Qt::CaseInsensitive) == 0) {
|
||||
appendGameLinkTag(cursor, fullWordUpToSpaceOrEnd);
|
||||
cursor.insertText(rest, defaultFormat);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// check word mentions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue