summaryrefslogtreecommitdiffhomepage
path: root/libs/web/src/template_lualib.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2012-11-26 14:26:43 +0000
committerJo-Philipp Wich <jow@openwrt.org>2012-11-26 14:26:43 +0000
commitf7b4fd2979e3a47c854638e4289883ba15e07705 (patch)
treebc82e0fd786e4c85bae57e93fd353c627e219bfd /libs/web/src/template_lualib.c
parente2f3b8923d2771245082a93d170699828c8d7107 (diff)
libs/web: various changes in template library
- rename sanitize_pcdata() and sanitize_utf8() to pcdata() and utf8() - implement striptags()
Diffstat (limited to 'libs/web/src/template_lualib.c')
-rw-r--r--libs/web/src/template_lualib.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/libs/web/src/template_lualib.c b/libs/web/src/template_lualib.c
index f40ef2d6ae..0d43641041 100644
--- a/libs/web/src/template_lualib.c
+++ b/libs/web/src/template_lualib.c
@@ -44,11 +44,11 @@ int template_L_parse(lua_State *L)
return rv;
}
-int template_L_sanitize_utf8(lua_State *L)
+int template_L_utf8(lua_State *L)
{
size_t len = 0;
const char *str = luaL_checklstring(L, 1, &len);
- char *res = sanitize_utf8(str, len);
+ char *res = utf8(str, len);
if (res != NULL)
{
@@ -61,11 +61,28 @@ int template_L_sanitize_utf8(lua_State *L)
return 0;
}
-int template_L_sanitize_pcdata(lua_State *L)
+int template_L_pcdata(lua_State *L)
{
size_t len = 0;
const char *str = luaL_checklstring(L, 1, &len);
- char *res = sanitize_pcdata(str, len);
+ char *res = pcdata(str, len);
+
+ if (res != NULL)
+ {
+ lua_pushstring(L, res);
+ free(res);
+
+ return 1;
+ }
+
+ return 0;
+}
+
+int template_L_striptags(lua_State *L)
+{
+ size_t len = 0;
+ const char *str = luaL_checklstring(L, 1, &len);
+ char *res = striptags(str, len);
if (res != NULL)
{
@@ -129,8 +146,9 @@ static int template_L_hash(lua_State *L) {
/* module table */
static const luaL_reg R[] = {
{ "parse", template_L_parse },
- { "sanitize_utf8", template_L_sanitize_utf8 },
- { "sanitize_pcdata", template_L_sanitize_pcdata },
+ { "utf8", template_L_utf8 },
+ { "pcdata", template_L_pcdata },
+ { "striptags", template_L_striptags },
{ "load_catalog", template_L_load_catalog },
{ "close_catalog", template_L_close_catalog },
{ "change_catalog", template_L_change_catalog },