test: Add two more urlDecode tests #29967

pull maflcko wants to merge 1 commits into bitcoin:master from maflcko:2404-test-urlDec- changing 1 files +3 −0
  1. maflcko commented at 6:35 am on April 26, 2024: member
    Trivial follow-up after #29904 (review)
  2. test: Add two more urlDecode tests fa55972a75
  3. DrahtBot commented at 6:35 am on April 26, 2024: contributor

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

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK laanwj, stickies-v, fjahr, Sjors

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  4. DrahtBot added the label Tests on Apr 26, 2024
  5. maflcko requested review from fjahr on Apr 26, 2024
  6. stickies-v approved
  7. stickies-v commented at 7:44 am on April 26, 2024: contributor
    ACK fa55972a758865a6bd0114afe72e51877896d495
  8. fjahr commented at 7:48 am on April 26, 2024: contributor

    ACK fa55972a758865a6bd0114afe72e51877896d495

    super-mini-nit: In the commit message, urlDecode is now UrlDecode

  9. in src/test/common_url_tests.cpp:57 in fa55972a75
    53@@ -54,6 +54,9 @@ BOOST_AUTO_TEST_CASE(decode_malformed_test) {
    54     BOOST_CHECK_EQUAL(UrlDecode(" %Z "), " %Z ");
    55     BOOST_CHECK_EQUAL(UrlDecode(" % X"), " % X");
    56 
    57+    BOOST_CHECK_EQUAL(UrlDecode("%%ffg"), "%\xffg");
    


    Sjors commented at 8:31 am on April 26, 2024:

    I had to scratch my head on this one…

    It iterates from left to right, the first thing it finds is %. It then tries if the next two characters are hex, which they are not, so it puts the literal % in the result. Then it moves to the next % which is followed by valid hex ff. Since 0xff is invalid unicode, we have to represent it with the escape sequence "\xff". And then there’s the regular character g.

  10. Sjors approved
  11. Sjors commented at 8:32 am on April 26, 2024: member
    utACK fa55972a758865a6bd0114afe72e51877896d495
  12. fanquake merged this on Apr 26, 2024
  13. fanquake closed this on Apr 26, 2024

  14. maflcko deleted the branch on Apr 26, 2024

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: 2024-06-29 07:13 UTC

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