1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-24 04:56:09 +02:00

xml_entities(): use function strbuf_addstr_xml_quoted()

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2012-11-25 12:08:35 +01:00 committed by Junio C Hamano
parent 5963c0367f
commit 37141f27d8

View File

@ -172,28 +172,7 @@ enum dav_header_flag {
static char *xml_entities(const char *s)
{
struct strbuf buf = STRBUF_INIT;
while (*s) {
size_t len = strcspn(s, "\"<>&");
strbuf_add(&buf, s, len);
s += len;
switch (*s) {
case '"':
strbuf_addstr(&buf, "&quot;");
break;
case '<':
strbuf_addstr(&buf, "&lt;");
break;
case '>':
strbuf_addstr(&buf, "&gt;");
break;
case '&':
strbuf_addstr(&buf, "&amp;");
break;
case 0:
return strbuf_detach(&buf, NULL);
}
s++;
}
strbuf_addstr_xml_quoted(&buf, s);
return strbuf_detach(&buf, NULL);
}