Enhancement: avoid isSanitized
feature from breaking HTTP body JSON API params, in some rare scenario of params includes UTF8 chars
#91
Labels
enhancement
New feature or request
Affected Lines
Known sample, but recommended to search more comprehensively.
midtrans-php/Midtrans/Sanitizer.php
Line 141 in 4929d87
midtrans-php/Midtrans/Sanitizer.php
Line 124 in 4929d87
https://github.com/search?q=repo%3AMidtrans%2Fmidtrans-php%20substr&type=code
Findings:
Reproducible evidence:
Issue Desc
When:
substr
-ed,Unexpected:
false
/ empty JSON.Midtrans API is returning API error. HTTP status code: 500 API response: {"status_code":"500","status_message":"Sorry. Our system is recovering from unexpected issues. Please retry.","id":"c99ccd6b-3174-4b25-907a-bb8e6a1d586d"}
Further: Seems PHP does not natively support UTF-8 char encoding (Chinese chars are UTF-8, which is more bytes than regular ASCII which PHP support).
Expected:
substr
&json_encode
should success produce proper JSON, not empty.Possible Solution:
[TBD] ... Probably use
mb_substr
to replacesubstr
usage, but need further check for any possible downsides (e.g. apparently not all PHP server env enable MB extension, as it is an optional non-default extension).Possible Workaround
\Midtrans\Config::$isSanitized = true;
to\Midtrans\Config::$isSanitized = false;
The text was updated successfully, but these errors were encountered: