Software /
code /
prosody
Comparison
util-src/encodings.c @ 10359:4ef785f45aa2
util.encodings: Strictly verify that the 'strict' *prep argument is a boolean
This is to prevent mistakes like nodeprep(username:gsub("a","b")) from
unintentionally invoking strict mode.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 30 Oct 2019 16:22:44 +0100 |
parent | 10357:72e6d0d7ff9b |
child | 10371:228338120009 |
comparison
equal
deleted
inserted
replaced
10358:a77d9b3885bb | 10359:4ef785f45aa2 |
---|---|
294 lua_pushnil(L); | 294 lua_pushnil(L); |
295 return 1; | 295 return 1; |
296 } | 296 } |
297 | 297 |
298 /* strict */ | 298 /* strict */ |
299 if(lua_toboolean(L, 2)) { | 299 if(!lua_isnoneornil(L, 2)) { |
300 flags = 0; | 300 luaL_checktype(L, 2, LUA_TBOOLEAN); |
301 if(lua_toboolean(L, 2)) { | |
302 flags = 0; | |
303 } | |
301 } | 304 } |
302 | 305 |
303 u_strFromUTF8(unprepped, 1024, &unprepped_len, input, input_len, &err); | 306 u_strFromUTF8(unprepped, 1024, &unprepped_len, input, input_len, &err); |
304 | 307 |
305 if(U_FAILURE(err)) { | 308 if(U_FAILURE(err)) { |
411 } | 414 } |
412 | 415 |
413 s = check_utf8(L, 1, &len); | 416 s = check_utf8(L, 1, &len); |
414 | 417 |
415 /* strict */ | 418 /* strict */ |
416 if(lua_toboolean(L, 2)) { | 419 if(!lua_isnoneornil(L, 2)) { |
417 flags = STRINGPREP_NO_UNASSIGNED; | 420 luaL_checktype(L, 2, LUA_TBOOLEAN); |
421 if(lua_toboolean(L, 2)) { | |
422 flags = STRINGPREP_NO_UNASSIGNED; | |
423 } | |
418 } | 424 } |
419 | 425 |
420 if(s == NULL || len >= 1024 || len != strlen(s)) { | 426 if(s == NULL || len >= 1024 || len != strlen(s)) { |
421 lua_pushnil(L); | 427 lua_pushnil(L); |
422 return 1; /* TODO return error message */ | 428 return 1; /* TODO return error message */ |