diff options
author | Mark Michelson <mmichelson@digium.com> | 2014-05-07 15:29:18 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2014-05-07 15:29:18 +0000 |
commit | 065bd7d7039a10663fb06be7808e741c3f79e7f6 (patch) | |
tree | 1879039cd14c4ddca7b3709aac1ea6b6cf23c1f7 /res/res_pjsip/presence_xml.c | |
parent | 9eae6c3f5bad40f3c23f34be9c8d33f67da49c72 (diff) |
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
Diffstat (limited to 'res/res_pjsip/presence_xml.c')
-rw-r--r-- | res/res_pjsip/presence_xml.c | 8 |
1 files changed, 7 insertions, 1 deletions
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; |