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

summarize the multibytes(utf8) payload stream maybe cause the content unreadable #588

Open
TheNorthMemory opened this issue Dec 22, 2023 · 0 comments

Comments

@TheNorthMemory
Copy link

PHP version: 8.3.0

Description

A community user was reported that, it was used the Laravel with Guzzle PSR7 packages, while these wanna tracing the RequestException by the dd function, they got an exception message unreadble, and then try to respond it as JSON which got that Malformed UTF-8 characters, possibly incorrectly encoded fatal error.

unreadable-message

Debugging that codes, the problem cames from Guzzle\Psr7\Message::bodySummary function with the default $truncateAt = 120 input.

For example, the utf8 payload is:

'{"code":"PARAM_ERROR","detail":{"location":"body","value":""},"message":"输入源“/body/sub_mchid”映射到字段“子商户号/二级商户号”必填性规则校验失败,此字段为必填项"}'

Stream of the $truncateAt position that is in byte charcode, but the 120 index payload, it was the half of the multibyte chacracter. This is caused the UTF8 character malformed.

Possible solution is that, detect the $truncateAt character whether or nor is the multibyte, while it is true, extra offset 1 or 2 bytes as of the bodySummary respond.

This issue is samilar to #561 .

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

No branches or pull requests

1 participant