@@ -289,51 +289,32 @@ PHPAPI php_url *php_url_parse_ex(char const *str, int length)
289
289
290
290
just_path :
291
291
292
- if ((p = memchr (s , '?' , (ue - s )))) {
293
- pp = memchr (s , '#' , (ue - s ));
294
-
295
- if (pp && pp < p ) {
296
- if (pp - s ) {
297
- ret -> path = estrndup (s , (pp - s ));
298
- php_replace_controlchars_ex (ret -> path , (pp - s ));
299
- }
300
- p = pp ;
301
- goto label_parse ;
302
- }
303
-
304
- if (p - s ) {
305
- ret -> path = estrndup (s , (p - s ));
306
- php_replace_controlchars_ex (ret -> path , (p - s ));
307
- }
308
-
309
- if (pp ) {
310
- if (pp - ++ p ) {
311
- ret -> query = estrndup (p , (pp - p ));
312
- php_replace_controlchars_ex (ret -> query , (pp - p ));
313
- }
314
- p = pp ;
315
- goto label_parse ;
316
- } else if (++ p - ue ) {
317
- ret -> query = estrndup (p , (ue - p ));
318
- php_replace_controlchars_ex (ret -> query , (ue - p ));
319
- }
320
- } else if ((p = memchr (s , '#' , (ue - s )))) {
321
- if (p - s ) {
322
- ret -> path = estrndup (s , (p - s ));
323
- php_replace_controlchars_ex (ret -> path , (p - s ));
292
+ e = ue ;
293
+ p = memchr (s , '#' , (e - s ));
294
+ if (p ) {
295
+ p ++ ;
296
+ if (p < e ) {
297
+ ret -> fragment = estrndup (p , (e - p ));
298
+ php_replace_controlchars_ex (ret -> fragment , (e - p ));
324
299
}
300
+ e = p - 1 ;
301
+ }
325
302
326
- label_parse :
303
+ p = memchr (s , '?' , (e - s ));
304
+ if (p ) {
327
305
p ++ ;
328
-
329
- if (ue - p ) {
330
- ret -> fragment = estrndup (p , (ue - p ));
331
- php_replace_controlchars_ex (ret -> fragment , (ue - p ));
306
+ if (p < e ) {
307
+ ret -> query = estrndup (p , (e - p ));
308
+ php_replace_controlchars_ex (ret -> query , (e - p ));
332
309
}
333
- } else {
334
- ret -> path = estrndup (s , (ue - s ));
335
- php_replace_controlchars_ex (ret -> path , (ue - s ));
310
+ e = p - 1 ;
336
311
}
312
+
313
+ if (s < e || s == ue ) {
314
+ ret -> path = estrndup (s , (e - s ));
315
+ php_replace_controlchars_ex (ret -> path , (e - s ));
316
+ }
317
+
337
318
return ret ;
338
319
}
339
320
/* }}} */
0 commit comments