@@ -295,24 +295,17 @@ class GenericUri {
295
295
// Look for auth (//([^/?#]*))?
296
296
auth_ = scheme_ + GetSchemeStringLength () + 1 ;
297
297
*auth_ = ' \0 ' ;
298
- if (start < len) {
299
- pos1 = start;
300
- while (pos1 < len) {
301
- if (uri[pos1] == ' /' && uri[pos1 + 1 ] == ' /' ) break ;
302
- pos1++;
303
- }
304
- if (pos1 == start) {
305
- pos2 = start + 2 ;
306
- while (pos2 < len) {
307
- if (uri[pos2] == ' /' ) break ;
308
- if (uri[pos2] == ' ?' ) break ;
309
- if (uri[pos2] == ' #' ) break ;
310
- pos2++;
311
- }
312
- std::memcpy (auth_, &uri[start], (pos2 - start) * sizeof (Ch));
313
- auth_[pos2 - start] = ' \0 ' ;
314
- start = pos2;
298
+ if (start < len - 1 && uri[start] == ' /' && uri[start + 1 ] == ' /' ) {
299
+ pos2 = start + 2 ;
300
+ while (pos2 < len) {
301
+ if (uri[pos2] == ' /' ) break ;
302
+ if (uri[pos2] == ' ?' ) break ;
303
+ if (uri[pos2] == ' #' ) break ;
304
+ pos2++;
315
305
}
306
+ std::memcpy (auth_, &uri[start], (pos2 - start) * sizeof (Ch));
307
+ auth_[pos2 - start] = ' \0 ' ;
308
+ start = pos2;
316
309
}
317
310
// Look for path ([^?#]*)
318
311
path_ = auth_ + GetAuthStringLength () + 1 ;
@@ -335,8 +328,8 @@ class GenericUri {
335
328
// Look for query (\?([^#]*))?
336
329
query_ = path_ + GetPathStringLength () + 1 ;
337
330
*query_ = ' \0 ' ;
338
- if (start < len) {
339
- pos2 = start;
331
+ if (start < len && uri[start] == ' ? ' ) {
332
+ pos2 = start + 1 ;
340
333
while (pos2 < len) {
341
334
if (uri[pos2] == ' #' ) break ;
342
335
pos2++;
@@ -350,7 +343,7 @@ class GenericUri {
350
343
// Look for fragment (#(.*))?
351
344
frag_ = query_ + GetQueryStringLength () + 1 ;
352
345
*frag_ = ' \0 ' ;
353
- if (start < len) {
346
+ if (start < len && uri[start] == ' # ' ) {
354
347
std::memcpy (frag_, &uri[start], (len - start) * sizeof (Ch));
355
348
frag_[len - start] = ' \0 ' ;
356
349
}
0 commit comments