Skip to content

Conversation

@0xNF
Copy link
Contributor

@0xNF 0xNF commented Feb 7, 2024

fix #17546

This PR is part of the effort to split PR #17548

Changes request parsing from checking .body.isNotEmpty to .bodyBytes.isNotEmpty, because .body implicitly converts to a utf-8 string, and will crash when trying to deserde data that isn't valid utf-8.

@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

…e.bodyBytes.isEmpty because .body implicitly converts to a utf-8 string which is will cause crashes when the data isnt utf-8 (OpenAPITools#17546)
@agilob
Copy link
Contributor

agilob commented Feb 7, 2024

How a byte array isn't a valid utf8 string(?)?

@kuhnroyal
Copy link
Contributor

No matching octet sequence or just unknown/invalid unicode.
Makes sense to me, but can anyone test this? :)

@0xNF
Copy link
Contributor Author

0xNF commented Feb 19, 2024

How a byte array isn't a valid utf8 string(?)?

For example, an endpoint that returns the bytes of a jpeg.
Or an endpoint that serves utf16 strings.

In my case it was image data that caused exceptions, but endpoints can serve any encoding of byte, and every encoding is not valid utf8.

@wing328
Copy link
Member

wing328 commented Feb 19, 2024

for testing, we can consider adding echo api client for dart. We already have an endpoint to return a gif, we can create another endpoint to return a utf6 string.

@0xNF ping me if you need help adding the Dart echo api client to perform integration tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] [Dart] API Responses incorrectly use .body instead of .bodyBytes when checking emptiness, which can crash for non-ut8 data

4 participants