comparison src/http/ngx_http_parse.c @ 3615:31e9677b15a1

allow spaces in URI
author Igor Sysoev <igor@sysoev.ru>
date Tue, 15 Jun 2010 09:31:19 +0000
parents 64bd39f03182
children e4cabc48b862
comparison
equal deleted inserted replaced
3614:4b4385492f2a 3615:31e9677b15a1
110 sw_schema, 110 sw_schema,
111 sw_schema_slash, 111 sw_schema_slash,
112 sw_schema_slash_slash, 112 sw_schema_slash_slash,
113 sw_host, 113 sw_host,
114 sw_port, 114 sw_port,
115 sw_host_http_09,
115 sw_after_slash_in_uri, 116 sw_after_slash_in_uri,
116 sw_check_uri, 117 sw_check_uri,
118 sw_check_uri_http_09,
117 sw_uri, 119 sw_uri,
118 sw_http_09, 120 sw_http_09,
119 sw_http_H, 121 sw_http_H,
120 sw_http_HT, 122 sw_http_HT,
121 sw_http_HTT, 123 sw_http_HTT,
355 * use single "/" from request line to preserve pointers, 357 * use single "/" from request line to preserve pointers,
356 * if request line will be copied to large client buffer 358 * if request line will be copied to large client buffer
357 */ 359 */
358 r->uri_start = r->schema_end + 1; 360 r->uri_start = r->schema_end + 1;
359 r->uri_end = r->schema_end + 2; 361 r->uri_end = r->schema_end + 2;
360 state = sw_http_09; 362 state = sw_host_http_09;
361 break; 363 break;
362 default: 364 default:
363 return NGX_HTTP_PARSE_INVALID_REQUEST; 365 return NGX_HTTP_PARSE_INVALID_REQUEST;
364 } 366 }
365 break; 367 break;
381 * use single "/" from request line to preserve pointers, 383 * use single "/" from request line to preserve pointers,
382 * if request line will be copied to large client buffer 384 * if request line will be copied to large client buffer
383 */ 385 */
384 r->uri_start = r->schema_end + 1; 386 r->uri_start = r->schema_end + 1;
385 r->uri_end = r->schema_end + 2; 387 r->uri_end = r->schema_end + 2;
386 state = sw_http_09; 388 state = sw_host_http_09;
387 break; 389 break;
388 default: 390 default:
389 return NGX_HTTP_PARSE_INVALID_REQUEST; 391 return NGX_HTTP_PARSE_INVALID_REQUEST;
390 } 392 }
391 break; 393 break;
394
395 /* space+ after "http://host[:port] " */
396 case sw_host_http_09:
397 switch (ch) {
398 case ' ':
399 break;
400 case CR:
401 r->http_minor = 9;
402 state = sw_almost_done;
403 break;
404 case LF:
405 r->http_minor = 9;
406 goto done;
407 case 'H':
408 r->http_protocol.data = p;
409 state = sw_http_H;
410 break;
411 default:
412 return NGX_HTTP_PARSE_INVALID_REQUEST;
413 }
414 break;
415
392 416
393 /* check "/.", "//", "%", and "\" (Win32) in URI */ 417 /* check "/.", "//", "%", and "\" (Win32) in URI */
394 case sw_after_slash_in_uri: 418 case sw_after_slash_in_uri:
395 419
396 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { 420 if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
399 } 423 }
400 424
401 switch (ch) { 425 switch (ch) {
402 case ' ': 426 case ' ':
403 r->uri_end = p; 427 r->uri_end = p;
404 state = sw_http_09; 428 state = sw_check_uri_http_09;
405 break; 429 break;
406 case CR: 430 case CR:
407 r->uri_end = p; 431 r->uri_end = p;
408 r->http_minor = 9; 432 r->http_minor = 9;
409 state = sw_almost_done; 433 state = sw_almost_done;
464 case '.': 488 case '.':
465 r->uri_ext = p + 1; 489 r->uri_ext = p + 1;
466 break; 490 break;
467 case ' ': 491 case ' ':
468 r->uri_end = p; 492 r->uri_end = p;
469 state = sw_http_09; 493 state = sw_check_uri_http_09;
470 break; 494 break;
471 case CR: 495 case CR:
472 r->uri_end = p; 496 r->uri_end = p;
473 r->http_minor = 9; 497 r->http_minor = 9;
474 state = sw_almost_done; 498 state = sw_almost_done;
501 case '\0': 525 case '\0':
502 return NGX_HTTP_PARSE_INVALID_REQUEST; 526 return NGX_HTTP_PARSE_INVALID_REQUEST;
503 } 527 }
504 break; 528 break;
505 529
530 /* space+ after URI */
531 case sw_check_uri_http_09:
532 switch (ch) {
533 case ' ':
534 break;
535 case CR:
536 r->http_minor = 9;
537 state = sw_almost_done;
538 break;
539 case LF:
540 r->http_minor = 9;
541 goto done;
542 case 'H':
543 r->http_protocol.data = p;
544 state = sw_http_H;
545 break;
546 default:
547 r->space_in_uri = 1;
548 state = sw_check_uri;
549 break;
550 }
551 break;
552
553
506 /* URI */ 554 /* URI */
507 case sw_uri: 555 case sw_uri:
508 556
509 if (usual[ch >> 5] & (1 << (ch & 0x1f))) { 557 if (usual[ch >> 5] & (1 << (ch & 0x1f))) {
510 break; 558 break;
547 case 'H': 595 case 'H':
548 r->http_protocol.data = p; 596 r->http_protocol.data = p;
549 state = sw_http_H; 597 state = sw_http_H;
550 break; 598 break;
551 default: 599 default:
552 return NGX_HTTP_PARSE_INVALID_REQUEST; 600 r->space_in_uri = 1;
601 state = sw_uri;
602 break;
553 } 603 }
554 break; 604 break;
555 605
556 case sw_http_H: 606 case sw_http_H:
557 switch (ch) { 607 switch (ch) {