muktihari / fit

A FIT SDK for decoding and encoding Garmin FIT files in Go supporting FIT Protocol V2.
BSD 3-Clause "New" or "Revised" License
42 stars 4 forks source link

fix: proto UnmarshalValue on handling string padding #436

Closed muktihari closed 2 months ago

muktihari commented 2 months ago

Strings may contains padding bytes. Previously, I thought that the padding only consist of zero bytes, but it turned out the padding bytes can be vary for example workout_step's notes (array: false): Screenshot from 2024-09-16 13-00-25

Since string in utf8 is terminated by zero, we cut the value up to zero. Now we will omit invalid utf8 character as well, since it does not comply with FIT's string spec.

It was first discovered when handling files from this thread: https://forums.garmin.com/developer/fit-sdk/f/discussion/383991/my-fit-file-that-i-combined-won-t-upload-to-garmin-connect#pifragment-1304=1

codecov-commenter commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (e2c16ec) to head (6ba6b98).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #436 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 42 42 Lines 3658 3659 +1 ========================================= + Hits 3658 3659 +1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.