Skip to content

test: Add two more urlDecode tests - #29967

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2404-test-urlDec-
Apr 26, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
maflcko:2404-test-urlDec-

Conversation

@maflcko

@maflcko maflcko commented Apr 26, 2024

Copy link
Copy Markdown
Member

Trivial follow-up after #29904 (comment)

@DrahtBot

DrahtBot commented Apr 26, 2024 •

Copy link
Copy Markdown
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.

@DrahtBot DrahtBot added the Tests label Apr 26, 2024
@maflcko
maflcko requested a review from fjahr April 26, 2024 06:35
@laanwj

laanwj commented Apr 26, 2024

Copy link
Copy Markdown
Member

Code review ACK fa55972

@stickies-v stickies-v left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ACK fa55972

@fjahr

fjahr commented Apr 26, 2024 •

Copy link
Copy Markdown
Contributor

ACK fa55972

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

@Sjors Sjors left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

utACK fa55972

BOOST_CHECK_EQUAL(UrlDecode(" %Z "), " %Z ");
BOOST_CHECK_EQUAL(UrlDecode(" % X"), " % X");

BOOST_CHECK_EQUAL(UrlDecode("%%ffg"), "%\xffg");

@Sjors Sjors Apr 26, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@fanquake
fanquake merged commit 7973a67 into bitcoin:master Apr 26, 2024
@maflcko
maflcko deleted the 2404-test-urlDec- branch April 26, 2024 08:50
@bitcoin bitcoin locked and limited conversation to collaborators Apr 26, 2025
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.

7 participants