MCPcopy Create free account
hub / github.com/apache/trafficserver / ts_lua_escape_uri

Function ts_lua_escape_uri

plugins/lua/ts_lua_crypto.cc:520–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

518}
519
520static int
521ts_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
553static int
554ts_lua_unescape_uri(lua_State *L)

Callers

nothing calls this directly

Calls 1

TSStringPercentEncodeFunction · 0.85

Tested by

no test coverage detected