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

No unicode normalization: spec and tests. #125

Merged
merged 2 commits into from
Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions doc/langdef.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ CEL Literal | Meaning
`"\xFF"` | String of "ÿ" (code point 255)
`b"\xFF"` | Sequence of byte 255 (_not_ UTF-8 of ÿ)

While strings must be sequences of valid Unicode code points, no Unicode
normalization is attempted on strings, as there are several normal forms, they
can be expensive to convert, and we don't know which is desired. If Unicode
normalization is desired, it should be performed outside of CEL, or done as a
custom extension function.

Likewise, no advanced collation is attempted on strings, as this depnds on the
normalization and can be locale-dependent. Strings are simply treated as
sequences of code points and are ordered with lexicographic ordering based on
the numeric value of the code points.

### Aggregate Values

Lists are ordered sequences of values.
Expand Down
18 changes: 18 additions & 0 deletions tests/simple/testdata/comparisons.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ section {
expr: "'a' == 'à'"
value: { bool_value: false }
}
test {
name: "no_string_normalization"
description: "Should not normalize Unicode."
expr: "'Am\\u00E9lie' == 'Ame\\u0301lie'"
value: { bool_value: false }
}
test {
name: "no_string_normalization_surrogate"
description: "Should not replace surrogate pairs."
expr: "'\\U0001F436' == '\\uD83D\\uDC36'"
value: { bool_value: false }
}
test {
name: "eq_null"
expr: "null == null"
Expand Down Expand Up @@ -379,6 +391,12 @@ section {
expr: "'a' < 'AB'"
value: { bool_value: false }
}
test {
name: "unicode_order_lexical"
description: "Compare the actual code points of the string, instead of decomposing ế into 'e' plus accent modifiers."
expr: "'f' < '\\u1EBF'"
value: { bool_value: true }
}
test {
name: "lt_bytes"
expr: "b'a' < b'b'"
Expand Down