Skip to content

Conversation

@nan01ab
Copy link
Contributor

@nan01ab nan01ab commented Dec 15, 2024

Description

According to

if ((str.Length - startIndex) != Length * 2) return false;

UInt160.TryParse parses a hex-string with 40 chars.
But leading or trailing whitespace when byte.TryParse with NumberStyles.HexNumber, so
UInt160.TryParse(" 1 2 3 45 000000000000000000000000000000", out _) will return true.
It's weird and unexpected.

Fixes # (issue)

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@nan01ab nan01ab changed the title fix: UInt160.TryParse when source has whitespaces [Fix]: UInt160.TryParse when source has whitespaces Dec 15, 2024
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

An unexpected one.

@shargon shargon merged commit 71aac33 into neo-project:master Dec 16, 2024
6 of 7 checks passed
@nan01ab nan01ab deleted the fix.UInt160-TryParse branch December 20, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants