Revision 3235

View differences:

libsylph/imap.c
1 1
/*
2 2
 * LibSylph -- E-Mail client library
3
 * Copyright (C) 1999-2012 Hiroyuki Yamamoto
3
 * Copyright (C) 1999-2013 Hiroyuki Yamamoto
4 4
 *
5 5
 * This library is free software; you can redistribute it and/or
6 6
 * modify it under the terms of the GNU Lesser General Public
......
63 63

  
64 64
#define QUOTE_IF_REQUIRED(out, str)					\
65 65
{									\
66
	if (*str != '"' && strpbrk(str, " \t(){}[]%&*") != NULL) {	\
66
	if (!str || *str == '\0') {					\
67
		Xstrdup_a(out, "\"\"", return IMAP_ERROR);		\
68
	} else if (strpbrk(str, " \t(){}[]%&*\"\\") != NULL) {		\
67 69
		gchar *__tmp;						\
68 70
		gint len;						\
71
		const gchar *p;						\
72
		gchar *tp;						\
69 73
									\
70
		len = strlen(str) + 3;					\
74
		len = strlen(str) * 2 + 3;				\
71 75
		Xalloca(__tmp, len, return IMAP_ERROR);			\
72
		g_snprintf(__tmp, len, "\"%s\"", str);			\
76
		tp = __tmp;						\
77
		*tp++ = '\"';						\
78
		for (p = str; *p != '\0'; p++) {			\
79
			if (*p == '\"' || *p == '\\')			\
80
				*tp++ = '\\';				\
81
			*tp++ = *p;					\
82
		}							\
83
		*tp++ = '\"';						\
84
		*tp = '\0';						\
73 85
		out = __tmp;						\
74 86
	} else {							\
75 87
		Xstrdup_a(out, str, return IMAP_ERROR);			\
......
3984 3996
{
3985 3997
	gchar *ref_, *mailbox_;
3986 3998

  
3987
	if (!ref) ref = "\"\"";
3988
	if (!mailbox) mailbox = "\"\"";
3999
	if (!ref) ref = "";
4000
	if (!mailbox) mailbox = "";
3989 4001

  
3990 4002
	QUOTE_IF_REQUIRED(ref_, ref);
3991 4003
	QUOTE_IF_REQUIRED(mailbox_, mailbox);
ChangeLog
1
2013-03-26
2

  
3
	* libsylph/imap.c: properly escape folder/username/password which
4
	  include double-quote or backslash.
5

  
1 6
2013-03-13
2 7

  
3 8
	* libsylph/mh.c: mh_scan_tree_recursive(): fixed rebuilding of folder

Also available in: Unified diff