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>maint
parent
5963c0367f
commit
37141f27d8
23
http-push.c
23
http-push.c
|
@ -172,28 +172,7 @@ enum dav_header_flag {
|
||||||
static char *xml_entities(const char *s)
|
static char *xml_entities(const char *s)
|
||||||
{
|
{
|
||||||
struct strbuf buf = STRBUF_INIT;
|
struct strbuf buf = STRBUF_INIT;
|
||||||
while (*s) {
|
strbuf_addstr_xml_quoted(&buf, s);
|
||||||
size_t len = strcspn(s, "\"<>&");
|
|
||||||
strbuf_add(&buf, s, len);
|
|
||||||
s += len;
|
|
||||||
switch (*s) {
|
|
||||||
case '"':
|
|
||||||
strbuf_addstr(&buf, """);
|
|
||||||
break;
|
|
||||||
case '<':
|
|
||||||
strbuf_addstr(&buf, "<");
|
|
||||||
break;
|
|
||||||
case '>':
|
|
||||||
strbuf_addstr(&buf, ">");
|
|
||||||
break;
|
|
||||||
case '&':
|
|
||||||
strbuf_addstr(&buf, "&");
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
return strbuf_detach(&buf, NULL);
|
|
||||||
}
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
return strbuf_detach(&buf, NULL);
|
return strbuf_detach(&buf, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue