Mercurial > hg > nginx-quic
comparison src/http/ngx_http_parse.c @ 7578:79bcbe7cd3f2
The "/." and "/.." at the end of URI should be normalized.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Tue, 08 Oct 2019 21:56:14 +0300 |
parents | 5a3426683251 |
children | 6208c5418c88 |
comparison
equal
deleted
inserted
replaced
7577:5a3426683251 | 7578:79bcbe7cd3f2 |
---|---|
1435 case '%': | 1435 case '%': |
1436 quoted_state = state; | 1436 quoted_state = state; |
1437 state = sw_quoted; | 1437 state = sw_quoted; |
1438 break; | 1438 break; |
1439 case '?': | 1439 case '?': |
1440 u--; | |
1440 r->args_start = p; | 1441 r->args_start = p; |
1441 goto args; | 1442 goto args; |
1442 case '#': | 1443 case '#': |
1444 u--; | |
1443 goto done; | 1445 goto done; |
1444 case '+': | 1446 case '+': |
1445 r->plus_in_uri = 1; | 1447 r->plus_in_uri = 1; |
1446 /* fall through */ | 1448 /* fall through */ |
1447 default: | 1449 default: |
1465 switch (ch) { | 1467 switch (ch) { |
1466 #if (NGX_WIN32) | 1468 #if (NGX_WIN32) |
1467 case '\\': | 1469 case '\\': |
1468 #endif | 1470 #endif |
1469 case '/': | 1471 case '/': |
1470 state = sw_slash; | 1472 case '?': |
1473 case '#': | |
1471 u -= 5; | 1474 u -= 5; |
1472 for ( ;; ) { | 1475 for ( ;; ) { |
1473 if (u < r->uri.data) { | 1476 if (u < r->uri.data) { |
1474 return NGX_HTTP_PARSE_INVALID_REQUEST; | 1477 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1475 } | 1478 } |
1477 u++; | 1480 u++; |
1478 break; | 1481 break; |
1479 } | 1482 } |
1480 u--; | 1483 u--; |
1481 } | 1484 } |
1485 if (ch == '?') { | |
1486 r->args_start = p; | |
1487 goto args; | |
1488 } | |
1489 if (ch == '#') { | |
1490 goto done; | |
1491 } | |
1492 state = sw_slash; | |
1482 break; | 1493 break; |
1483 case '%': | 1494 case '%': |
1484 quoted_state = state; | 1495 quoted_state = state; |
1485 state = sw_quoted; | 1496 state = sw_quoted; |
1486 break; | 1497 break; |
1487 case '?': | |
1488 r->args_start = p; | |
1489 goto args; | |
1490 case '#': | |
1491 goto done; | |
1492 case '+': | 1498 case '+': |
1493 r->plus_in_uri = 1; | 1499 r->plus_in_uri = 1; |
1494 /* fall through */ | 1500 /* fall through */ |
1495 default: | 1501 default: |
1496 state = sw_usual; | 1502 state = sw_usual; |
1561 } | 1567 } |
1562 } | 1568 } |
1563 | 1569 |
1564 if (state == sw_quoted || state == sw_quoted_second) { | 1570 if (state == sw_quoted || state == sw_quoted_second) { |
1565 return NGX_HTTP_PARSE_INVALID_REQUEST; | 1571 return NGX_HTTP_PARSE_INVALID_REQUEST; |
1572 } | |
1573 | |
1574 if (state == sw_dot) { | |
1575 u--; | |
1576 | |
1577 } else if (state == sw_dot_dot) { | |
1578 u -= 5; | |
1579 | |
1580 for ( ;; ) { | |
1581 if (u < r->uri.data) { | |
1582 return NGX_HTTP_PARSE_INVALID_REQUEST; | |
1583 } | |
1584 | |
1585 if (*u == '/') { | |
1586 u++; | |
1587 break; | |
1588 } | |
1589 | |
1590 u--; | |
1591 } | |
1566 } | 1592 } |
1567 | 1593 |
1568 done: | 1594 done: |
1569 | 1595 |
1570 r->uri.len = u - r->uri.data; | 1596 r->uri.len = u - r->uri.data; |