Skip to content

Conversation

achow101
Copy link
Member

@achow101 achow101 commented Sep 8, 2019

Fixes some places where wallet names and address labels which contain valid html or other interpreted characters are displayed incorrectly.

In the send coins dialog, if the wallet name or the address label contains valid html, then the html would be shown rather than the literal string for the wallet name or label. This PR fixes that so the true name or label is shown.

The Open Wallet menu would incorrectly show wallet names with ampersands (&). For some reason, Qt removes the first ampersand in a string. So by replacing the first ampersand with 2 ampersands, the correct number of ampersands will be shown.

Fixes the HTML escaping issues in #16820

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK ba9f82a for the ampersand issue. I don't know how to test the send coins dialog issue. The code looks fine.

@@ -375,6 +375,8 @@ void BitcoinGUI::createActions()
for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
const std::string& path = i.first;
QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
// Menu items remove single &. Single & are shown when && is in the string, but only the first occurrence. So replace only the first & with &&
Copy link
Member

@jonatack jonatack Sep 8, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: long comment; perhaps split it over 2 lines if you have to retouch.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonatack Given you'll need to rebase #16822, you can fix the comment there if you want. I don't mind either way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appended the change to cad3ab5 while rebasing.

@darosior
Copy link
Member

darosior commented Sep 8, 2019

ACK ba9f82a

@kristapsk
Copy link
Contributor

For some reason, Qt removes the first ampersand in a string.

First ampersand is removed because it is used to specify hot key. Replacing it with "&&" is recommended method. https://doc.qt.io/qt-5/qmenubar.html#details

@achow101
Copy link
Member Author

achow101 commented Sep 8, 2019

I don't know how to test the send coins dialog issue.

Make a wallet named like <b>A</b>. It should appear as <b>A</b> everywhere. But in the send coins dialog, on master, it will appear as A (bold A). The send coins dialog is the confirmation dialog that appears after you click Send on the send page.

When you are on the send page, set a label for the recipient in the same way that the wallet name was set. Then check the send coins dialog.

Copy link
Contributor

@kristapsk kristapsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ba9f82a (tested both cases with and without these changes)

@jonatack
Copy link
Member

jonatack commented Sep 8, 2019

Thanks @achow101.

@jonatack
Copy link
Member

jonatack commented Sep 8, 2019

ACK ba9f82a, I have reviewed the code and manually tested these changes, and agree they can be merged.

Additional test to my previous manual testing, with send label supplied as <b>A</b>:

On master:

Are you sure you want to send?
Please, review your transaction.

0.00100000 BTC from wallet 'PR16826' to 'A'  (A in bold)

This PR:

Are you sure you want to send?
Please, review your transaction.

0.00100000 BTC from wallet 'PR16826' to '<b>A</b>'

@kristapsk
Copy link
Contributor

There is similar issue with close wallet dialog, maybe could be fixed with this PR too.

image

@jonatack
Copy link
Member

jonatack commented Sep 8, 2019

@kristapsk good catch, reproduced your issue.

@achow101
Copy link
Member Author

achow101 commented Sep 8, 2019

Fixed the escaping in the close dialog. Also noticed that notifications needed HTML escaping too, so I've added escapes for the wallet name and address label in transaction notifications.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 8, 2019

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16822 (gui: Create wallet menu option follow-ups by jonatack)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@kristapsk
Copy link
Contributor

Tested close wallet dialog, is ok now.

@@ -75,7 +75,7 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
{
QMessageBox box(parent);
box.setWindowTitle(tr("Close wallet"));
box.setText(tr("Are you sure you wish to close wallet <i>%1</i>?").arg(wallet_model->getDisplayName()));
box.setText(tr("Are you sure you wish to close wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(wallet_model->getDisplayName())));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re DrahtBot: this PR and #16822 both touch this one line. Trivial rebase for the whichever is not merged first.

@laanwj
Copy link
Member

laanwj commented Sep 9, 2019

Untested ACK, thanks for adding proper escaping, ad52f05

Copy link
Member

@fanquake fanquake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ad52f05

Ampersand escaping. master:
alice_bob_master

#16826:
alice_bob_16826

HTML escaping. master:
slanty_master

#16826
slanty_16826

fanquake added a commit that referenced this pull request Sep 9, 2019
…ddress labels

ad52f05 Escape ampersands (&) in wallet names in Open Wallet menu (Andrew Chow)
2c530ea HTML escape address labels in more dialogs and notifications (Andrew Chow)
1770a97 HTML escape the wallet name in more dialogs and notifications (Andrew Chow)

Pull request description:

  Fixes some places where wallet names and address labels which contain valid html or other interpreted characters are displayed incorrectly.

  In the send coins dialog, if the wallet name or the address label contains valid html, then the html would be shown rather than the literal string for the wallet name or label. This PR fixes that so the true name or label is shown.

  The Open Wallet menu would incorrectly show wallet names with ampersands (`&`). For some reason, Qt removes the first ampersand in a string. So by replacing the first ampersand with 2 ampersands, the correct number of ampersands will be shown.

  Fixes the HTML escaping issues in #16820

ACKs for top commit:
  laanwj:
    Untested ACK, thanks for adding proper escaping, ad52f05
  fanquake:
    ACK ad52f05

Tree-SHA512: 264bef28a8061c7f43cc30c3e04b361c614ea78b9915e8763c44553c8967131b066db500977fa6130de1f8874b9bba59e630486c58e1e3c5c165555105a6c254
@fanquake fanquake merged commit ad52f05 into bitcoin:master Sep 9, 2019
fanquake added a commit to fanquake/bitcoin that referenced this pull request Sep 16, 2019
cad3ab5 gui: fix autofocus in CreateWalletActivity::askPassphrase() (Jon Atack)
539d940 gui: fix passphrase labels/tooltip in createwalletdialog/askpassphrasedialog (Jon Atack)
43aa9b0 gui: rename encrypt(), blank(), and askPasshprase() (Jon Atack)

Pull request description:

  Closes bitcoin#16820. The wallet [name escaping issue](bitcoin#15450 (review)) in that issue predates bitcoin#15450 and is fixed by bitcoin#16826.

  - [x]  rename encrypt() to encryptWallet(), and blank() to makeBlankWallet() // EDIT: updated to
          isEncryptWalletChecked()
          isDisablePrivateKeysChecked()
          isMakeBlankWalletChecked()
  - [x]  fix naming of askPasshprase() to askPassphrase()
  - [x]  fix passphrase labels and tooltip in createwalletdialog.ui and askpassphrasedialog.ui
  - [x]  fix grammar of labels in askpassphrase dialog and WalletController::closeWallet
  - [x]  fix autofocus in CreateWalletActivity::askPassphrase()

  Squashed down to three commits.

  Reviewers, to test manually: build, launch the gui wallet, and look at labels/tooltips/focus with the create wallet, encrypt wallet, change password, and close wallet commands.

ACKs for top commit:
  jb55:
    Approach ACK cad3ab5
  instagibbs:
    code review and tACK cad3ab5
  fanquake:
    ACK cad3ab5

Tree-SHA512: b441fbf8f8cd370dd692bac24f0d3c1b32fc7d947b6c3a2c9ba7cf0bc175a72b3460440f2f10f7632c0e8e0f8e65fe15615a30c46e2c7763bf258c504b457dd6
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Sep 16, 2019
cad3ab5 gui: fix autofocus in CreateWalletActivity::askPassphrase() (Jon Atack)
539d940 gui: fix passphrase labels/tooltip in createwalletdialog/askpassphrasedialog (Jon Atack)
43aa9b0 gui: rename encrypt(), blank(), and askPasshprase() (Jon Atack)

Pull request description:

  Closes bitcoin#16820. The wallet [name escaping issue](bitcoin#15450 (review)) in that issue predates bitcoin#15450 and is fixed by bitcoin#16826.

  - [x]  rename encrypt() to encryptWallet(), and blank() to makeBlankWallet() // EDIT: updated to
          isEncryptWalletChecked()
          isDisablePrivateKeysChecked()
          isMakeBlankWalletChecked()
  - [x]  fix naming of askPasshprase() to askPassphrase()
  - [x]  fix passphrase labels and tooltip in createwalletdialog.ui and askpassphrasedialog.ui
  - [x]  fix grammar of labels in askpassphrase dialog and WalletController::closeWallet
  - [x]  fix autofocus in CreateWalletActivity::askPassphrase()

  Squashed down to three commits.

  Reviewers, to test manually: build, launch the gui wallet, and look at labels/tooltips/focus with the create wallet, encrypt wallet, change password, and close wallet commands.

ACKs for top commit:
  jb55:
    Approach ACK cad3ab5
  instagibbs:
    code review and tACK cad3ab5
  fanquake:
    ACK cad3ab5

Tree-SHA512: b441fbf8f8cd370dd692bac24f0d3c1b32fc7d947b6c3a2c9ba7cf0bc175a72b3460440f2f10f7632c0e8e0f8e65fe15615a30c46e2c7763bf258c504b457dd6
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 21, 2019
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 21, 2019
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 21, 2019
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 23, 2019
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 23, 2019
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 23, 2019
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 15, 2020
Summary:
Qt interprets HTML and uses the first ampersand in a string to specify hot key.
Escape HTML and ampersands in wallet names to display them unambigously.

Backport of Core [[bitcoin/bitcoin#16826 | PR16826]]

Test Plan:
`ninja && ninja check`

Run `bitcoin-qt` and create a new wallet called "Hel&lo <b>World</b>,
and make sure it is display as a raw string everywhere
(send transaction dialog, Open Wallet menu)

Reviewers: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Reviewed By: O1 Bitcoin ABC, #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D7931
kwvg added a commit to kwvg/dash that referenced this pull request Nov 6, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Dec 5, 2021
kwvg added a commit to kwvg/dash that referenced this pull request Dec 5, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants