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

Function ts_lua_base64_decode

plugins/lua/ts_lua_crypto.cc:488–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488static int
489ts_lua_base64_decode(lua_State *L)
490{
491 u_char *src;
492 u_char *dst;
493 size_t slen;
494 size_t dlen;
495
496 size_t length;
497
498 if (lua_gettop(L) != 1) {
499 return luaL_error(L, "expecting one argument");
500 }
501
502 if (lua_isnil(L, 1)) {
503 src = (u_char *)"";
504 slen = 0;
505 } else {
506 src = (u_char *)luaL_checklstring(L, 1, &slen);
507 }
508
509 dlen = TS_LUA_MAX_STR_LENGTH;
510 dst = static_cast<u_char *>(lua_newuserdata(L, dlen));
511
512 if (TS_SUCCESS == TSBase64Decode((const char *)src, slen, (unsigned char *)dst, dlen, &length)) {
513 lua_pushlstring(L, (char *)dst, length);
514 return 1;
515 } else {
516 return luaL_error(L, "base64 decoding error");
517 }
518}
519
520static int
521ts_lua_escape_uri(lua_State *L)

Callers

nothing calls this directly

Calls 1

TSBase64DecodeFunction · 0.85

Tested by

no test coverage detected