Merge branch 'mh/unify-xml-in-imap-send-and-http-push'
Update imap-send to reuse xml quoting code from http-push codepath, clean up some code, and fix a small bug. * mh/unify-xml-in-imap-send-and-http-push: wrap_in_html(): process message in bulk rather than line-by-line wrap_in_html(): use strbuf_addstr_xml_quoted() imap-send: change msg_data from storing (ptr, len) to storing strbuf imap-send: correctly report errors reading from stdin imap-send: store all_msgs as a strbuf lf_to_crlf(): NUL-terminate msg_data::data xml_entities(): use function strbuf_addstr_xml_quoted() Add new function strbuf_add_xml_quoted()
This commit is contained in:
26
strbuf.c
26
strbuf.c
@ -425,6 +425,32 @@ void strbuf_add_lines(struct strbuf *out, const char *prefix,
|
||||
strbuf_complete_line(out);
|
||||
}
|
||||
|
||||
void strbuf_addstr_xml_quoted(struct strbuf *buf, const char *s)
|
||||
{
|
||||
while (*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;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
static int is_rfc3986_reserved(char ch)
|
||||
{
|
||||
switch (ch) {
|
||||
|
Reference in New Issue
Block a user