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

Function ts_lua_unescape_uri

plugins/lua/ts_lua_crypto.cc:553–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553static int
554ts_lua_unescape_uri(lua_State *L)
555{
556 size_t len, dlen;
557 u_char *src, *dst;
558
559 size_t length;
560
561 if (lua_gettop(L) != 1) {
562 return luaL_error(L, "expecting one argument for ts.unescape_uri(...)");
563 }
564
565 if (lua_isnil(L, 1)) {
566 lua_pushliteral(L, "");
567 return 1;
568 }
569
570 src = (u_char *)luaL_checklstring(L, 1, &len);
571 if (len == 0) {
572 return 1;
573 }
574
575 /* the unescaped string can not be larger, but need to account for terminating null. */
576 dlen = len + 1;
577 dst = static_cast<u_char *>(lua_newuserdata(L, dlen));
578
579 if (TS_SUCCESS == TSStringPercentDecode((const char *)src, len, (char *)dst, dlen, &length)) {
580 lua_pushlstring(L, (char *)dst, length);
581 return 1;
582 } else {
583 return luaL_error(L, "percent decoding error");
584 }
585}

Callers

nothing calls this directly

Calls 1

TSStringPercentDecodeFunction · 0.85

Tested by

no test coverage detected