canonical / craft-cli

https://canonical-craft-cli.readthedocs-hosted.com/en/latest/
GNU Lesser General Public License v3.0
9 stars 14 forks source link

fix: handle errors when decoding bytes from subprocesses #222

Closed tigarmo closed 6 months ago

tigarmo commented 6 months ago

Since these bytes come from the output of unknown processes, there is no guarantee that they are valid utf-8 text. We also have no way to know what encoding they have (if any), so the best we can do is replace the invalid bytes with the usual unicode marker for that.

Fixes #221

codecov[bot] commented 6 months ago

Codecov Report

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

Comparison is base (8b61db8) 94.81% compared to head (a5eacf6) 94.81%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #222 +/- ## ======================================= Coverage 94.81% 94.81% ======================================= Files 7 7 Lines 1080 1080 Branches 200 200 ======================================= Hits 1024 1024 Misses 53 53 Partials 3 3 ```

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

tigarmo commented 6 months ago

Confirmed manually that this works in Snapcraft:

Building my-part                                                                                                                                                                            
:: + echo -e 'hi \x96 bye'                                                                                                                                                                  
:: hi � bye                                                                                                                                                                                 
Staging my-part