Ensure invalid JSON characters are stripped before sent to the browser.
This fixes the issue where invalid characters could go through a
websocket connection without proper validation and thus breaking the
connection with a client.
#include "settings.h"
#include "ui.h"
#include "util.h"
+#include "websocket.h"
#include "xmalloc.h"
typedef struct GPanel_
@@ -264,6 +265,8 @@ escape_json_other (GJSON * json, char **s)
} else {
char buf[2];
snprintf (buf, sizeof buf, "%c", **s);
+
+ if (ws_validate_string (buf, 1) == 0)
pjson (json, "%s", buf);
}
}
