Better feedback when unprintable characters in Bitcoin address #1325

issue sgornick opened this issue on May 16, 2012
  1. sgornick commented at 8:39 PM on May 16, 2012: none

    There are some problems with people copying and pasting an address where the address includes an unprintable character.

    For example, some web apps will inject an #8203; into a long word so that a line-break / word wrap will occur. But the user doing a copy and paste won't see this character.

    When trying to paste this into the PayTo: field of v0.6.2, the paste does not succeed. There is no feedback given as to why this paste does not occur.

    In previous versions (perhaps v0.5.x/) apparently the paste will success but the validation fails on send (highlights the field in red). Still though there is no further feedback as to what the problem is.

    The user then feels the problem is with Bitcoin-Qt as that same copy and paste on an EWallet (e.g., on Mt. Gox website) works fine (presumably because they strip out nonprintable characters from an address?)

    Here's an example of users reporting this issue:

    Here's what the "view source" for the web page shows: 1G5apmPvo2iTtmkNWAHTCET7​Y842Ufijs8

  2. laanwj commented at 8:57 PM on May 16, 2012: member

    Sneaky. But I think this would be pretty simple to solve; in the correction phase of BitcoinAddressValidator::validate, delete these characters from the string.

  3. gmaxwell commented at 9:07 PM on May 16, 2012: contributor

    I don't generally like the idea of the validator "fixing" broken addresses, because it's perfectly possible for one character variations to also be valid. ... but the case of random entities stuffed in, that seems pretty safe to fix to me. Perhaps we should decode any entities, then strip only whitespace/linebreaks?

  4. laanwj commented at 10:33 PM on May 16, 2012: member

    I don't like the idea of decoding entities at all.

    From what I understood it is not about entities stuffed in, but actual unicode characters. Those show up in html source as entities, but appear as normal utf-8 characters when copy/pasted into a plain text field. Those QChar(8203) are easy and safe to filter out, along with other whitespace/linebreaks.

  5. gmaxwell commented at 10:35 PM on May 16, 2012: contributor

    Okay, to be clear— I think stripping whitespace is okay. I don't think stripping or replacing other characters is okay. To the extent that whitespace might come in the form of entities I'd be okay with stripping that to. I didn't mean to advocate decoding entities if not needed.

  6. laanwj commented at 10:41 PM on May 16, 2012: member

    We already replace other characters: l and I are replaced by 1, 0 and O by o. This is just a convenience for the user and does not give any confusion in base58.

    Edit: but I agree that, beyond that, we should not try to 'fix' the addresses. Edit.2: I also think you mean another validator, this is the one used for input fields in bitcoin-qt, not the internal validator used in the core. The user is able to visually inspect the result before submitting.

  7. laanwj referenced this in commit db8e5ce8ee on May 17, 2012
  8. laanwj commented at 1:01 PM on May 17, 2012: member

    See #1329

  9. gmaxwell commented at 1:09 PM on May 17, 2012: contributor

    I must have missed that change going in, as I specifically remembered NAKing #552 . I continue to think that the character substitution is a bad idea (in a way that whitespace removal isn't).

  10. laanwj commented at 1:35 PM on May 17, 2012: member

    It was already in there from the beginning of bitcoin-qt. I think it is harmless, at most. Users typing in base58 addresses from paper, for example, should not have to care if something is a 0, o or O as they look visually the same and AFAIK that was the intended idea of base58.

  11. laanwj referenced this in commit 25047eb3e9 on May 21, 2012
  12. laanwj commented at 4:54 PM on May 21, 2012: member

    Fixed

  13. laanwj closed this on May 21, 2012

  14. luke-jr referenced this in commit 087fc28f7d on Jun 17, 2012
  15. coblee referenced this in commit e8a372ec47 on Jul 17, 2012
  16. suprnurd referenced this in commit b6be968c2f on Dec 5, 2017
  17. lateminer referenced this in commit 3338d0ab56 on Jan 22, 2019
  18. lateminer referenced this in commit 91566195ee on May 6, 2020
  19. MarcoFalke locked this on Sep 8, 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-13 18:16 UTC

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