From 065bd7d7039a10663fb06be7808e741c3f79e7f6 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Wed, 7 May 2014 15:29:18 +0000 Subject: Improve XML sanitization in NOTIFYs, especially for presence subtypes and messages. Embedded carriage return line feed combinations may appear in presence subtypes and messages since they may be derived from user input in an instant messenger client. As such, they need to be properly escaped so that XML parsers do not vomit when the messages are received. ........ Merged revisions 413372 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413381 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- res/res_pjsip/presence_xml.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'res/res_pjsip') diff --git a/res/res_pjsip/presence_xml.c b/res/res_pjsip/presence_xml.c index 31e06eba4..9ed07caa1 100644 --- a/res/res_pjsip/presence_xml.c +++ b/res/res_pjsip/presence_xml.c @@ -43,7 +43,7 @@ void ast_sip_sanitize_xml(const char *input, char *output, size_t len) output[0] = '\0'; - while ((break_point = strpbrk(copy, "<>\"&'"))) { + while ((break_point = strpbrk(copy, "<>\"&'\n\r"))) { char to_escape = *break_point; *break_point = '\0'; @@ -65,6 +65,12 @@ void ast_sip_sanitize_xml(const char *input, char *output, size_t len) case '\'': strncat(output, "'", len); break; + case '\r': + strncat(output, " ", len); + break; + case '\n': + strncat(output, " ", len); + break; }; copy = break_point + 1; -- cgit v1.2.3