-void escape_luastr(struct template_buffer *out, const char *s, unsigned int l,
+char * striptags(const char *s, unsigned int l)
+{
+ struct template_buffer *buf = buf_init(l);
+ unsigned char *ptr = (unsigned char *)s;
+ unsigned char *end = ptr + l;
+ unsigned char *tag;
+ unsigned char prev;
+ char esq[8];
+ int esl;
+
+ for (prev = ' '; ptr < end; ptr++)
+ {
+ if ((*ptr == '<') && ((ptr + 2) < end) &&
+ ((*(ptr + 1) == '/') || isalpha(*(ptr + 1))))
+ {
+ for (tag = ptr; tag < end; tag++)
+ {
+ if (*tag == '>')
+ {
+ if (!isspace(prev))
+ buf_putchar(buf, ' ');
+
+ ptr = tag;
+ prev = ' ';
+ break;
+ }
+ }
+ }
+ else if (isspace(*ptr))
+ {
+ if (!isspace(prev))
+ buf_putchar(buf, *ptr);
+
+ prev = *ptr;
+ }
+ else
+ {
+ switch(*ptr)
+ {
+ case '"':
+ case '\'':
+ case '<':
+ case '>':
+ case '&':
+ esl = snprintf(esq, sizeof(esq), "&#%i;", *ptr);
+ buf_append(buf, esq, esl);
+ break;
+
+ default:
+ buf_putchar(buf, *ptr);
+ break;
+ }
+
+ prev = *ptr;
+ }
+ }
+
+ return buf_destroy(buf);
+}
+
+void luastr_escape(struct template_buffer *out, const char *s, unsigned int l,