Tidied escaping xml

This commit is contained in:
James Booth
2012-11-06 22:53:59 +00:00
parent 9872708755
commit 92ae93de33
3 changed files with 22 additions and 14 deletions

View File

@@ -105,3 +105,16 @@ str_contains(char str[], int size, char ch)
return 0;
}
char *
encode_xml(const char * const xml)
{
char *coded_msg = str_replace(xml, "&", "&");
char *coded_msg2 = str_replace(coded_msg, "<", "&lt;");
char *coded_msg3 = str_replace(coded_msg2, ">", "&gt;");
free(coded_msg);
free(coded_msg2);
return coded_msg3;
}