MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / decode_mail_url

Function decode_mail_url

modules/cpl_c/cpl_parser.c:122–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120#define MAX_EMAIL_SUBJECT_SIZE 32
121
122static inline char *decode_mail_url(char *p, char *p_end, char *url,
123 unsigned char *nr_attr)
124{
125 static char buf[ MAX_EMAIL_HDR_SIZE ];
126 int c, foo;
127 unsigned short hdr_len;
128 unsigned short *len;
129 int max_len;
130 int status;
131
132 /* init */
133 hdr_len = 0;
134 max_len = 0;
135 status = EMAIL_TO;
136 (*nr_attr) ++;
137 set_attr_type(p, TO_ATTR, p_end, error); /* attr type */
138 len = ((unsigned short*)(p)); /* attr val's len */
139 *len = 0; /* init the len */
140 p += 2;
141
142 /* parse the whole url */
143 do {
144 /* extract a char from the encoded url */
145 if (*url=='+') {
146 /* substitute a blank for a plus */
147 c=' ';
148 url++;
149 /* Look for a hex encoded character */
150 } else if ( (*url=='%') && *(url+1) && *(url+2) ) {
151 /* hex encoded - convert to a char */
152 c = hex2int(url[1]);
153 foo = hex2int(url[2]);
154 if (c==-1 || foo==-1) {
155 LM_ERR("non-ASCII escaped "
156 "character in mail url [%.*s]\n", 3, url);
157 goto error;
158 }
159 c = (char)(c<<4 | foo);
160 url += 3;
161 } else {
162 /* normal character - just copy it without changing */
163 c = *url;
164 url++;
165 }
166
167 /* finally we got a character !! */
168 switch (c) {
169 case '?':
170 switch (status) {
171 case EMAIL_TO:
172 if (*len==0) {
173 LM_ERR("empty TO "
174 "address found in MAIL node!\n");
175 goto error;
176 }
177 if (((*len)&0x0001)==1) p++;
178 *len = htons(*len);
179 hdr_len = 0;

Callers 1

encode_mail_attrFunction · 0.85

Calls 1

hex2intFunction · 0.85

Tested by

no test coverage detected