hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit a2e9cfc788855bb1fb636e90b9ddbf19a87564f9
parent 6391a5c245f57ff59eae1e4538076601e853916b
Author: Kirill Primak <vyivel@eclair.cafe>
Date:   Sat, 17 Sep 2022 19:04:34 +0300

encoding::utf8: validate rune in encoderune()

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>

Diffstat:
Mencoding/utf8/encode.ha | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/encoding/utf8/encode.ha b/encoding/utf8/encode.ha @@ -6,6 +6,9 @@ // encoderune. export fn encoderune(r: rune) []u8 = { let ch = r: u32, n = 0z, first = 0u8; + assert((ch < 0xD800 || ch > 0xDFFF) && ch <= 0x10FFFF, + "the rune is not a valid Unicode codepoint"); + if (ch < 0x80) { first = 0; n = 1;