summaryrefslogtreecommitdiff
path: root/py/objstr.h
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2022-08-24 12:22:57 +1000
committerDamien George <damien@micropython.org>2022-08-26 16:45:46 +1000
commit6c3d8d38bfbe24c3d810f89f546ac947cf0cb66d (patch)
treead9cd46fbe8242c0764216a814836d8ddc0983ce /py/objstr.h
parent3a910b15650636efc58bce48cc1bfa0debfd375c (diff)
py/objstr: Always validate utf-8 for mp_obj_new_str.
All uses of this are either tiny strings or not-known-to-be-safe. Update comments for mp_obj_new_str_copy and mp_obj_new_str_of_type. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/objstr.h')
-rw-r--r--py/objstr.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objstr.h b/py/objstr.h
index 78441feda..6c6735bf5 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -88,8 +88,8 @@ mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t
void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len);
mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args);
-mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte *data, size_t len);
-mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte *data, size_t len);
+mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte *data, size_t len); // for type=str, input data must be valid utf-8
+mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte *data, size_t len); // for type=str, will check utf-8 (raises UnicodeError)
mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);