Skip to content

[BUG] Bytes to string conversion function does not error for invalid code points #716

Closed

Description

@timostamm

Describe the bug

According to the language definition,

string(bytes) -> string converts a byte sequence to a UTF-8 string, errors for invalid code points.

However, cel-java does not error for invalid code points.

To Reproduce

string(b"\xff")

Expected behavior

I would expect a runtime error, but the expression evaluates to "�" instead.

Additional context

bytes_to_string calls ByteString::toStringUtf8. It should probably check ByteString::isValidUtf8 first, and raise an error if that returns false.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions