URLs containing a / after the address no longer cause parsing errors. #4622

pull rnicoll wants to merge 1 commits into bitcoin:master from rnicoll:master-uri-parse changing 1 files +4 −0
  1. rnicoll commented at 6:57 PM on August 2, 2014: contributor

    In some cases under Windows a / is appended to bitcoin: URIs sent from browser to the client. This patch catches that case and removes the /.

  2. rnicoll commented at 1:42 PM on August 3, 2014: contributor

    Tested with:

    bitcoin-qt -testnet bitcoin:n4dqmiBSWCTLnJRs4FXRxeHVAhZJhyPGCR bitcoin-qt -testnet bitcoin:n4dqmiBSWCTLnJRs4FXRxeHVAhZJhyPGCR/ bitcoin-qt -testnet bitcoin:n4dqmiBSWCTLnJRs4FXRxeHVAhZJhyPGCR/?amount=100

    With 0.9.2 the latter two fail, with the revised patch all three are parsed as valid URIs and the prompt to complete payment is shown after startup.

  3. laanwj commented at 1:46 PM on August 3, 2014: member

    What are these cases? I'd like to know why this corruption happens in the first place. Do we do something wrong with escaping?

  4. rnicoll commented at 1:50 PM on August 3, 2014: contributor

    It's only something I'm seeing arising in Windows, but for some reason bitcoin: URIs are arriving with the client with a / on the end, as if they're being treated as URLs by some intermediary which rewrites them. Bitcoin is fine in theory, as the URI shouldn't have a / injected, but as it happens it seems practical to handle it.

    The last test case was suggested as an extreme example, I haven't seen a / injected mid-URI, but as the code handles the possibility it's good to verify it.

  5. laanwj commented at 1:52 PM on August 3, 2014: member

    OK. Weird. I've never heard this reported before.

  6. rnicoll commented at 1:54 PM on August 3, 2014: contributor

    I'll come back with more detail later, under the wrong OS right now.

  7. laanwj commented at 1:55 PM on August 3, 2014: member

    Something 'intermediating' between the browser and Bitcoin Core does sound vaguely scary, by the way. I hope it's not a man in the middle attack :)

  8. rnicoll commented at 1:57 PM on August 3, 2014: contributor

    I meant it looks like the OS takes the URI and modifies it. Still, this is fairly much why the client verifies payments before they're sent, right? :)

  9. cdecker commented at 3:52 PM on August 3, 2014: contributor

    Does this have an impact on people (wrongfully) using URIs with the bitcoin:// prefix, or are these broken anyway? Splitting by '/' feels awkward when a more explicit if-else checking for the last char would have done the trick.

  10. rnicoll commented at 12:25 AM on August 4, 2014: contributor

    @cdecker No, the rewrite to replace "bitcoin://" with "bitcoin:" occurs before this step, at around line 167 of guiutil.cpp

  11. rnicoll commented at 10:18 PM on August 4, 2014: contributor

    Reconfirmed the problem under Windows 7 with Chrome, and I think found why it occurs...

    Looking at https://chain.so/address/BTC/14nsgXjL7xCEXFf8UkGCm9KnSTTFBDKqcn (just a random address that's been used recently), the "Send Bitcoin" link has bitcoin:// in it, which somehow triggers a / being appended to the URI as well. Fixing the URI in the page does also resolve this.

  12. laanwj commented at 12:54 PM on August 5, 2014: member

    OK - they shouldn't be using bitcoin:// in the first place. But we remove the //, so it's fine with me to remove the trailing slash too.

    I agree with @cdecker that splitting and then taking the first feels awkward though. I'd prefer a more specific if(uri.path().endsWith("/")) check.

  13. laanwj added the label GUI on Aug 6, 2014
  14. laanwj added the label Improvement on Aug 6, 2014
  15. rnicoll commented at 9:39 PM on August 7, 2014: contributor

    Not sure why we got a bunch of random commits first update... anyway, that should be it just removing any ending / now.

  16. cdecker commented at 9:41 PM on August 7, 2014: contributor

    Thanks, that looks a lot better.

  17. in src/qt/guiutil.cpp:None in dec6c09805 outdated
     116 | @@ -117,6 +117,10 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
     117 |  
     118 |      SendCoinsRecipient rv;
     119 |      rv.address = uri.path();
     120 | +    // Trim any leading forward slash which may have been added by the OS
     121 | +    if (rv.address.endsWith("/")) {
     122 | +      rv.address.truncate(rv.address.length() - 1);
    


    Diapolo commented at 5:50 AM on August 8, 2014:

    Nit: Indentation (use 4 spaces).

  18. in src/qt/guiutil.cpp:None in dec6c09805 outdated
     116 | @@ -117,6 +117,10 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
     117 |  
     118 |      SendCoinsRecipient rv;
     119 |      rv.address = uri.path();
     120 | +    // Trim any leading forward slash which may have been added by the OS
    


    laanwj commented at 6:24 AM on August 8, 2014:

    is this a leading or trailing forward slash? :imp:

  19. laanwj commented at 6:26 AM on August 8, 2014: member

    ACK after nit

  20. URLs containing a / after the address no longer cause parsing errors. c7f3876d4a
  21. rnicoll commented at 6:14 PM on August 8, 2014: contributor

    Once more, with feeling...

  22. BitcoinPullTester commented at 6:28 PM on August 8, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4622_c7f3876d4af37cfd6e587d0ab7ddbeaedda27857/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  23. laanwj merged this on Aug 11, 2014
  24. laanwj closed this on Aug 11, 2014

  25. laanwj referenced this in commit 85af3856e7 on Aug 11, 2014
  26. rnicoll deleted the branch on Aug 29, 2014
  27. 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-21 18:15 UTC

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