xml_entities(): use function strbuf_addstr_xml_quoted()
authorMichael Haggerty <mhagger@alum.mit.edu>
Sun, 25 Nov 2012 11:08:35 +0000 (12:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Nov 2012 21:30:52 +0000 (13:30 -0800)
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-push.c

index 8701c1215d21cd0413c1d69be91b309984cf6b1f..9923441a4ec74cfdfd3c36b1be41762c04697bdd 100644 (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);
 }