Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

url: treat empty port as default #483

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion http_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,6 @@ http_parse_host(const char * buf, struct http_parser_url *u, int found_at) {
case s_http_host_v6:
case s_http_host_v6_zone_start:
case s_http_host_v6_zone:
case s_http_host_port_start:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior of http_parser_parse_url(is_connect=1) in that it'll now allow CONNECT hostname: as valid input, doesn't it?

case s_http_userinfo:
case s_http_userinfo_start:
return 1;
Expand Down
25 changes: 19 additions & 6 deletions test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2825,6 +2825,25 @@ const struct url_test url_tests[] =
,.rv=0
}

, {.name="proxy empty port"
,.url="http://hostname:/"
,.is_connect=0
,.u=
{.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH)
,.port=0
,.field_data=
{{ 0, 4 } /* UF_SCHEMA */
,{ 7, 8 } /* UF_HOST */
,{ 0, 0 } /* UF_PORT */
,{ 16, 1 } /* UF_PATH */
,{ 0, 0 } /* UF_QUERY */
,{ 0, 0 } /* UF_FRAGMENT */
,{ 0, 0 } /* UF_USERINFO */
}
}
,.rv=0
}

, {.name="CONNECT request"
,.url="hostname:443"
,.is_connect=1
Expand Down Expand Up @@ -3059,12 +3078,6 @@ const struct url_test url_tests[] =
,.rv=1
}

, {.name="proxy empty port"
,.url="http://hostname:/"
,.is_connect=0
,.rv=1
}

, {.name="CONNECT with basic auth"
,.url="a:b@hostname:443"
,.is_connect=1
Expand Down