strip_string
trims by number of chars instead of bytes
#2634
Labels
Type: Bug
Something isn't working
strip_string
trims by number of chars instead of bytes
#2634
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.39.2
Issue
The
strip_string
function isn't working properly.Here we calculate the size of the string in bytes as
length
. But then when we actually determine that the string needs trimming, we trimlength
characters from the string instead oflength
bytes. We also then potentially report the wrong number in the metadata.Both
é
andê
are two-byte large, making the string"éê"
4 bytes long. Yetstrip_string
will not strip it to two bytes.length
will be set to4
.True
, because4 > 2
."éê"
to two (characters/code points), as opposed to the encoded bytes representation.Solution
Probably something to the effect of
The
[: max_bytes - 3]
part might end up cutting a code point in two;.decode
witherrors="ignore"
will ignore any malformed codepoints.The text was updated successfully, but these errors were encountered: