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

Function decode_uri

modules/uac/replace.c:132–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132static inline int decode_uri( str *src , str *dst)
133{
134 static char buf[MAX_URI_SIZE];
135 int block;
136 int n;
137 int idx;
138 int end;
139 int i,j;
140 char c;
141
142 /* Count '-' at end and disregard them */
143 for( n=0,i=src->len-1; src->s[i]=='-'; i--)
144 n++;
145
146 dst->len = ((src->len * 6) >> 3) - n;
147 dst->s = buf;
148 if (dst->len>MAX_URI_SIZE)
149 {
150 LM_ERR("uri too long\n");
151 return -1;
152 }
153
154 end = src->len - n;
155 for ( i=0,idx=0 ; i<end ; idx+=3 )
156 {
157 /* Assemble three bytes into an int from four "valid" characters */
158 block = 0;
159 for ( j=0; j<4 && i<end ; j++)
160 {
161 c = dec_table64[(unsigned char)src->s[i++]];
162 if ( c<0 )
163 {
164 LM_ERR("invalid base64 string\"%.*s\"\n",src->len,src->s);
165 return -1;
166 }
167 block += c << (18 - 6*j);
168 }
169
170 /* Add the bytes */
171 for ( j=0,n=16 ; j<3 && idx+j< dst->len; j++,n-=8 )
172 buf[idx+j] = (char) ((block >> n) & 0xff);
173 }
174
175 return 0;
176}
177
178
179static inline struct lump* get_display_anchor(struct sip_msg *msg,

Callers 1

restore_uriFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected