File tree Expand file tree Collapse file tree 2 files changed +6
-21
lines changed Expand file tree Collapse file tree 2 files changed +6
-21
lines changed Original file line number Diff line number Diff line change @@ -698,7 +698,9 @@ func parseHost(host string) (string, error) {
698
698
return "" , errors .New ("invalid IP-literal" )
699
699
}
700
700
return "[" + unescapedHostname + "]" + unescapedColonPort , nil
701
- } else if i := strings .LastIndex (host , ":" ); i != - 1 {
701
+ } else if i := strings .Index (host , ":" ); i != - 1 {
702
+ // IPv4address / reg-name
703
+ // E.g. 1.2.3.4, 1.2.3.4:80, example.com, example.com:80
702
704
colonPort := host [i :]
703
705
if ! validOptionalPort (colonPort ) {
704
706
return "" , fmt .Errorf ("invalid port %q after host" , colonPort )
Original file line number Diff line number Diff line change @@ -506,26 +506,6 @@ var urltests = []URLTest{
506
506
},
507
507
"" ,
508
508
},
509
- {
510
- // Malformed IPv6 but still accepted.
511
- "http://2b01:e34:ef40:7730:8e70:5aff:fefe:edac:8080/foo" ,
512
- & URL {
513
- Scheme : "http" ,
514
- Host : "2b01:e34:ef40:7730:8e70:5aff:fefe:edac:8080" ,
515
- Path : "/foo" ,
516
- },
517
- "" ,
518
- },
519
- {
520
- // Malformed IPv6 but still accepted.
521
- "http://2b01:e34:ef40:7730:8e70:5aff:fefe:edac:/foo" ,
522
- & URL {
523
- Scheme : "http" ,
524
- Host : "2b01:e34:ef40:7730:8e70:5aff:fefe:edac:" ,
525
- Path : "/foo" ,
526
- },
527
- "" ,
528
- },
529
509
{
530
510
"http://[2b01:e34:ef40:7730:8e70:5aff:fefe:edac]:8080/foo" ,
531
511
& URL {
@@ -735,6 +715,9 @@ var parseRequestURLTests = []struct {
735
715
{"https://[0:0::test.com]:80" , false },
736
716
{"https://[2001:db8::test.com]" , false },
737
717
{"https://[test.com]" , false },
718
+ {"https://1:2:3:4:5:6:7:8" , false },
719
+ {"https://1:2:3:4:5:6:7:8:80" , false },
720
+ {"https://example.com:80:" , false },
738
721
}
739
722
740
723
func TestParseRequestURI (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments