comparison src/address.c @ 411:9b93c0a3bd8c

Ensure lvals, rvals and components of address strucs are stripped.
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 12:06:33 +0100
parents bc9a7845b53a
children
comparison
equal deleted inserted replaced
410:cff967b2f51e 411:9b93c0a3bd8c
35 create_address_qualified(gchar *path, gboolean is_rfc821, gchar *domain) 35 create_address_qualified(gchar *path, gboolean is_rfc821, gchar *domain)
36 { 36 {
37 address *addr = create_address(path, is_rfc821); 37 address *addr = create_address(path, is_rfc821);
38 38
39 if (addr && !addr->domain) { 39 if (addr && !addr->domain) {
40 addr->domain = g_strdup(domain); 40 addr->domain = g_strstrip(g_strdup(domain));
41 } 41 }
42 return addr; 42 return addr;
43 } 43 }
44 44
45 /* nothing special about pipes here, but its only called for that purpose */ 45 /* nothing special about pipes here, but its only called for that purpose */
48 { 48 {
49 address *addr = g_malloc(sizeof(address)); 49 address *addr = g_malloc(sizeof(address));
50 50
51 if (addr) { 51 if (addr) {
52 memset(addr, 0, sizeof(address)); 52 memset(addr, 0, sizeof(address));
53 addr->address = g_strchomp(g_strdup(path)); 53 addr->address = g_strstrip(g_strdup(path));
54 addr->local_part = g_strdup(addr->address); 54 addr->local_part = g_strstrip(g_strdup(addr->address));
55 addr->domain = g_strdup("localhost"); /* quick hack */ 55 addr->domain = g_strdup("localhost"); /* quick hack */
56 } 56 }
57 return addr; 57 return addr;
58 } 58 }
59 59
76 return NULL; 76 return NULL;
77 } 77 }
78 if (!(addr = g_malloc(sizeof(address)))) { 78 if (!(addr = g_malloc(sizeof(address)))) {
79 return NULL; 79 return NULL;
80 } 80 }
81 addr->address = g_strdup(orig->address); 81 addr->address = g_strstrip(g_strdup(orig->address));
82 addr->local_part = l_part ? g_strdup(l_part) : 82 addr->local_part = g_strstrip(l_part ? g_strdup(l_part) :
83 g_strdup(orig->local_part); 83 g_strdup(orig->local_part));
84 addr->domain = dom ? g_strdup(dom) : g_strdup(orig->domain); 84 addr->domain = g_strstrip(dom ? g_strdup(dom) :
85 g_strdup(orig->domain));
85 addr->flags = 0; 86 addr->flags = 0;
86 addr->children = NULL; 87 addr->children = NULL;
87 addr->parent = NULL; 88 addr->parent = NULL;
88 return addr; 89 return addr;
89 } 90 }
162 gchar* 163 gchar*
163 addr_string(address *addr) 164 addr_string(address *addr)
164 { 165 {
165 static gchar *buffer = NULL; 166 static gchar *buffer = NULL;
166 167
167 if (!addr) {
168 g_free(buffer);
169 buffer = NULL;
170 return NULL;
171 }
172 if (buffer) { 168 if (buffer) {
173 g_free(buffer); 169 g_free(buffer);
170 }
171 if (!addr) {
172 return NULL;
174 } 173 }
175 if (!*addr->local_part) { 174 if (!*addr->local_part) {
176 buffer = g_strdup("<>"); 175 buffer = g_strdup("<>");
177 } else { 176 } else {
178 buffer = g_strdup_printf("<%s@%s>", 177 buffer = g_strdup_printf("<%s@%s>",