lean4-htt/src/Init/System
Mario Carneiro 62cdb51ed5
feat: UTF-8 string validation (#3958)
Previously, there was a function `opaque fromUTF8Unchecked : ByteArray
-> String` which would convert a list of bytes into a string, but as the
name implies it does not validate that the string is UTF-8 before doing
so and as a result it produces unsound results in the compiler (because
the lean model of `String` indirectly asserts UTF-8 validity). This PR
replaces that function by
```lean
opaque validateUTF8 (a : @& ByteArray) : Bool

opaque fromUTF8 (a : @& ByteArray) (h : validateUTF8 a) : String
```
so that while the function is still "unchecked", we have a proof witness
that the string is valid. To recover the original, actually unchecked
version, use `lcProof` or other unsafe methods to produce the proof
witness.

Because this was the only `ByteArray -> String` conversion function, it
was used in several places in an unsound way (e.g. reading untrusted
input from IO and treating it as UTF-8). These have been replaced by
`fromUTF8?` or `fromUTF8!` as appropriate.
2024-04-20 18:36:37 +00:00
..
FilePath.lean fix: update System.FilePath.parent to handle edge cases for absolute paths (#3645) 2024-03-26 05:09:44 +00:00
IO.lean feat: UTF-8 string validation (#3958) 2024-04-20 18:36:37 +00:00
IOError.lean feat: log2 for Fin and UInts 2022-11-29 01:05:06 +01:00
Mutex.lean chore: use deriving Nonempty 2022-12-22 03:48:15 +01:00
Platform.lean feat: System.Platform.target (#3207) 2024-01-24 12:11:00 +00:00
Promise.lean refactor: make Promise implementation opaque (#3273) 2024-02-09 10:43:41 +00:00
ST.lean feat: code action resolvers 2022-10-20 11:20:42 -07:00
Uri.lean feat: UTF-8 string validation (#3958) 2024-04-20 18:36:37 +00:00