Do additional character escaping for wallet names and address labels #16826

pull achow101 wants to merge 3 commits into bitcoin:master from achow101:escape-wallet-name changing 4 files +7 −5
  1. achow101 commented at 4:32 AM on September 8, 2019: member

    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

  2. fanquake added the label GUI on Sep 8, 2019
  3. in src/qt/bitcoingui.cpp:378 in ba9f82a3ec outdated
     374 | @@ -375,6 +375,8 @@ void BitcoinGUI::createActions()
     375 |              for (const std::pair<const std::string, bool>& i : m_wallet_controller->listWalletDir()) {
     376 |                  const std::string& path = i.first;
     377 |                  QString name = path.empty() ? QString("["+tr("default wallet")+"]") : QString::fromStdString(path);
     378 | +                // Menu items remove single &. Single & are shown when && is in the string, but only the first occurrence. So replace only the first & with &&
    


    jonatack commented at 9:55 AM on September 8, 2019:

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


    promag commented at 9:50 PM on September 8, 2019:

    fanquake commented at 8:54 AM on September 9, 2019:

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


    jonatack commented at 9:08 AM on September 9, 2019:
  4. jonatack commented at 10:05 AM on September 8, 2019: member

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

  5. darosior commented at 11:39 AM on September 8, 2019: member

    ACK ba9f82a3ec81b8cd8fd729e43b87e93debbd7fba

  6. kristapsk commented at 3:26 PM on September 8, 2019: 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

  7. achow101 commented at 3:59 PM on September 8, 2019: member

    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.

  8. kristapsk approved
  9. kristapsk commented at 5:02 PM on September 8, 2019: contributor

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

  10. jonatack commented at 7:10 PM on September 8, 2019: member

    Thanks @achow101.

  11. jonatack commented at 7:32 PM on September 8, 2019: member

    ACK ba9f82a3ec81b8cd8fd729e43b87e93debbd7fba, 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>'
    
  12. kristapsk commented at 7:44 PM on September 8, 2019: contributor

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

    image

  13. jonatack commented at 7:47 PM on September 8, 2019: member

    @kristapsk good catch, reproduced your issue.

  14. HTML escape the wallet name in more dialogs and notifications 1770a972d4
  15. HTML escape address labels in more dialogs and notifications 2c530ea2ad
  16. Escape ampersands (&) in wallet names in Open Wallet menu ad52f054f6
  17. achow101 force-pushed on Sep 8, 2019
  18. achow101 commented at 8:42 PM on September 8, 2019: member

    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.

  19. DrahtBot commented at 9:13 PM on September 8, 2019: member

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--174a7506f384e20aa4161008e828411d-->

    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.

  20. kristapsk commented at 10:16 PM on September 8, 2019: contributor

    Tested close wallet dialog, is ok now.

  21. in src/qt/walletcontroller.cpp:78 in ad52f054f6
      74 | @@ -75,7 +75,7 @@ void WalletController::closeWallet(WalletModel* wallet_model, QWidget* parent)
      75 |  {
      76 |      QMessageBox box(parent);
      77 |      box.setWindowTitle(tr("Close wallet"));
      78 | -    box.setText(tr("Are you sure you wish to close wallet <i>%1</i>?").arg(wallet_model->getDisplayName()));
      79 | +    box.setText(tr("Are you sure you wish to close wallet <i>%1</i>?").arg(GUIUtil::HtmlEscape(wallet_model->getDisplayName())));
    


    jonatack commented at 6:52 AM on September 9, 2019:

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

  22. laanwj commented at 7:18 AM on September 9, 2019: member

    Untested ACK, thanks for adding proper escaping, ad52f054f67374dc46e0096d1e2f593d6372a2df

  23. fanquake approved
  24. fanquake commented at 8:44 AM on September 9, 2019: member

    ACK ad52f054f67374dc46e0096d1e2f593d6372a2df

    Ampersand escaping. master: alice_bob_master

    #16826: alice_bob_16826

    HTML escaping. master: slanty_master

    #16826 slanty_16826

  25. fanquake referenced this in commit 4c329d43a5 on Sep 9, 2019
  26. fanquake merged this on Sep 9, 2019
  27. fanquake closed this on Sep 9, 2019

  28. fanquake referenced this in commit a953429a0e on Sep 16, 2019
  29. sidhujag referenced this in commit 2b7ff1f581 on Sep 16, 2019
  30. luke-jr referenced this in commit 29c75f2a69 on Sep 21, 2019
  31. luke-jr referenced this in commit ce48c26407 on Sep 21, 2019
  32. luke-jr referenced this in commit c978662bc4 on Sep 21, 2019
  33. luke-jr referenced this in commit 982c09a616 on Sep 23, 2019
  34. luke-jr referenced this in commit ca3e3c4934 on Sep 23, 2019
  35. luke-jr referenced this in commit ddb313b6c1 on Sep 23, 2019
  36. jasonbcox referenced this in commit 5d4729852a on Oct 15, 2020
  37. kittywhiskers referenced this in commit e8a53351a7 on Nov 6, 2021
  38. kittywhiskers referenced this in commit b18211fa3e on Dec 5, 2021
  39. kittywhiskers referenced this in commit d7281c82ef on Dec 5, 2021
  40. MarcoFalke locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 21:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me