Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormatException with an unparseable hex number #105

Open
xPaw opened this issue Sep 15, 2024 · 2 comments
Open

FormatException with an unparseable hex number #105

xPaw opened this issue Sep 15, 2024 · 2 comments
Labels

Comments

@xPaw
Copy link
Member

xPaw commented Sep 15, 2024

"a" {
	"key" "0x11223344556677[]"
}

It passes the 0x prefix and 18 total length check but then fails to parse from hex. Valve's code kind of doesn't care because they do loose checks on the a/A characters and then math it.

I also noticed we check for 0x case insensitive, but valve only checks for lower case x.

@xPaw xPaw added the bug label Sep 15, 2024
@xPaw xPaw transferred this issue from ValveResourceFormat/ValveResourceFormat Sep 15, 2024
@yaakov-h
Copy link
Member

"loose checks on the a/A characters"?

What is this expected to be parsed as - what value does it result in?

@xPaw
Copy link
Member Author

xPaw commented Sep 16, 2024

"loose checks on the a/A characters"?

They don't check the ranges fully.

				for( int i=2; i < 2 + 16; i++ )
				{
					char digit = value[i];
					if ( digit >= 'a' ) 
						digit -= 'a' - ( '9' + 1 );
					else
						if ( digit >= 'A' )
							digit -= 'A' - ( '9' + 1 );
					retVal = ( retVal * 16 ) + ( digit - '0' );
				}

What is this expected to be parsed as

Looking at that code, probably nothing useful. Maybe we should fallback to not parsing it and return a string?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants