summaryrefslogtreecommitdiffstats
path: root/src/web_buffer.c
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2017-01-24 15:21:09 +0000
committerLennart Weller <lhw@ring0.de>2017-01-24 15:21:09 +0000
commit3ed3b02ed96ddab1c084811f3579b3a2aec83e04 (patch)
tree7a61ab288ae47800c4f11be5677d6ad8288dcd98 /src/web_buffer.c
parentNew upstream version 1.4.0+dfsg (diff)
downloadnetdata-3ed3b02ed96ddab1c084811f3579b3a2aec83e04.tar.xz
netdata-3ed3b02ed96ddab1c084811f3579b3a2aec83e04.zip
New upstream version 1.5.0+dfsgupstream/1.5.0+dfsg
Diffstat (limited to 'src/web_buffer.c')
-rw-r--r--src/web_buffer.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/web_buffer.c b/src/web_buffer.c
index 93ba782af..6203db0f7 100644
--- a/src/web_buffer.c
+++ b/src/web_buffer.c
@@ -113,6 +113,8 @@ void buffer_print_llu(BUFFER *wb, unsigned long long uvalue)
void buffer_strcat(BUFFER *wb, const char *txt)
{
+ // buffer_sprintf(wb, "%s", txt);
+
if(unlikely(!txt || !*txt)) return;
buffer_need_bytes(wb, 1);
@@ -143,6 +145,26 @@ void buffer_strcat(BUFFER *wb, const char *txt)
}
}
+void buffer_strcat_htmlescape(BUFFER *wb, const char *txt)
+{
+ char b[2] = { [0] = '\0', [1] = '\0' };
+
+ while(*txt) {
+ switch(*txt) {
+ case '&': buffer_strcat(wb, "&amp;"); break;
+ case '<': buffer_strcat(wb, "&lt;"); break;
+ case '>': buffer_strcat(wb, "&gt;"); break;
+ case '"': buffer_strcat(wb, "&quot;"); break;
+ case '/': buffer_strcat(wb, "&#x2F;"); break;
+ case '\'': buffer_strcat(wb, "&#x27;"); break;
+ default: {
+ b[0] = *txt;
+ buffer_strcat(wb, b);
+ }
+ }
+ txt++;
+ }
+}
void buffer_snprintf(BUFFER *wb, size_t len, const char *fmt, ...)
{