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

fix: consistency on treating invalid strings #175

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

muktihari
Copy link
Owner

In proto.Unmarshal, the SDK will remove any UTF-8 Null-Terminated String (0x00) from the string or []string value. To make consistency on how we should treat strings, all functions or methods that returning strings should return strings without 0x00, and all functions or methods that validate invalid strings should check for both empty string and 0x00, invalid if the result of this is true -> value == "" || value == "\x00".

Value marshaler will check whether a string is end with 0x00, if it does not end with 0x00 will automatically add it. If the users intentionally add multiple 0x00 it should allow it. In cases where message definitions differ only slightly, such as when creating FieldDescription messages with minor variations in the FieldName value (type: []string), it make sense to add 0x00 padding so that the length of the strings (the byte size of the FieldName value) become the same, this will reduce message definition interleave as it can be treated using the same message definition.

@muktihari muktihari added the enhancement New feature or request label Apr 10, 2024
@muktihari muktihari self-assigned this Apr 10, 2024
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (564b029) to head (fa46952).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #175   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           42        42           
  Lines         3471      3471           
=========================================
  Hits          3471      3471           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@muktihari muktihari merged commit 7017468 into master Apr 10, 2024
4 checks passed
@muktihari muktihari deleted the fix/consistency-of-an-invalid-string branch April 10, 2024 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants