| 518 | } |
| 519 | |
| 520 | static int |
| 521 | ts_lua_escape_uri(lua_State *L) |
| 522 | { |
| 523 | size_t len, dlen; |
| 524 | u_char *src, *dst; |
| 525 | |
| 526 | size_t length; |
| 527 | |
| 528 | if (lua_gettop(L) != 1) { |
| 529 | return luaL_error(L, "expecting one argument for ts.escape_uri(...)"); |
| 530 | } |
| 531 | |
| 532 | if (lua_isnil(L, 1)) { |
| 533 | lua_pushliteral(L, ""); |
| 534 | return 1; |
| 535 | } |
| 536 | |
| 537 | src = (u_char *)luaL_checklstring(L, 1, &len); |
| 538 | if (len == 0) { |
| 539 | return 1; |
| 540 | } |
| 541 | |
| 542 | dlen = TS_LUA_MAX_STR_LENGTH; |
| 543 | dst = static_cast<u_char *>(lua_newuserdata(L, dlen)); |
| 544 | |
| 545 | if (TS_SUCCESS == TSStringPercentEncode((const char *)src, len, (char *)dst, dlen, &length, nullptr)) { |
| 546 | lua_pushlstring(L, (char *)dst, length); |
| 547 | return 1; |
| 548 | } else { |
| 549 | return luaL_error(L, "percent encoding error"); |
| 550 | } |
| 551 | } |
| 552 | |
| 553 | static int |
| 554 | ts_lua_unescape_uri(lua_State *L) |
nothing calls this directly
no test coverage detected