File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -247,9 +247,9 @@ int URIParser::parse(const char *str, ParsedURI& uri)
247247
248248 int start_idx[URI_PART_ELEMENTS] = {0 };
249249 int end_idx[URI_PART_ELEMENTS] = {0 };
250- int pre_state = URI_SCHEME;;
251- int i;
250+ int pre_state = URI_SCHEME;
252251 bool in_ipv6 = false ;
252+ int i;
253253
254254 for (i = 0 ; str[i]; i++)
255255 {
@@ -268,7 +268,7 @@ int URIParser::parse(const char *str, ParsedURI& uri)
268268 pre_state = URI_HOST;
269269 i += 2 ;
270270 if (str[i] == ' [' )
271- in_ipv6= true ;
271+ in_ipv6 = true ;
272272 else
273273 start_idx[URI_USERINFO] = i;
274274
@@ -341,6 +341,7 @@ int URIParser::parse(const char *str, ParsedURI& uri)
341341 break ;
342342 }
343343 }
344+
344345 if (pre_state != URI_PART_ELEMENTS)
345346 end_idx[pre_state] = i;
346347
@@ -369,6 +370,7 @@ int URIParser::parse(const char *str, ParsedURI& uri)
369370 break ;
370371 }
371372 }
373+
372374 end_idx[pre_state] = i + strlen (str + i);
373375 }
374376
@@ -398,13 +400,15 @@ int URIParser::parse(const char *str, ParsedURI& uri)
398400 return -1 ;
399401 }
400402
401- if (i == URI_HOST && str[start_idx[i]] == ' [' )
403+ if (i == URI_HOST && str[start_idx[i]] == ' [' &&
404+ str[end_idx[i] - 1 ] == ' ]' )
402405 {
403406 len -= 2 ;
404407 memcpy (*dst[i], str + start_idx[i] + 1 , len);
405408 }
406409 else
407410 memcpy (*dst[i], str + start_idx[i], len);
411+
408412 (*dst[i])[len] = ' \0 ' ;
409413 }
410414 else
You can’t perform that action at this time.
0 commit comments