File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1625,10 +1625,25 @@ impl Url {
1625
1625
if host == "" && SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
1626
1626
return Err ( ParseError :: EmptyHost ) ;
1627
1627
}
1628
+ let mut host_substr = host;
1629
+ // Otherwise, if c is U+003A (:) and the [] flag is unset, then
1630
+ if !host. starts_with ( '[' ) || !host. ends_with ( ']' ) {
1631
+ match host. find ( ':' ) {
1632
+ Some ( 0 ) => {
1633
+ // If buffer is the empty string, validation error, return failure.
1634
+ return Err ( ParseError :: InvalidDomainCharacter ) ;
1635
+ }
1636
+ // Let host be the result of host parsing buffer
1637
+ Some ( colon_index) => {
1638
+ host_substr = & host[ ..colon_index] ;
1639
+ }
1640
+ None => { }
1641
+ }
1642
+ }
1628
1643
if SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
1629
- self . set_host_internal ( Host :: parse ( host ) ?, None )
1644
+ self . set_host_internal ( Host :: parse ( host_substr ) ?, None ) ;
1630
1645
} else {
1631
- self . set_host_internal ( Host :: parse_opaque ( host ) ?, None )
1646
+ self . set_host_internal ( Host :: parse_opaque ( host_substr ) ?, None ) ;
1632
1647
}
1633
1648
} else if self . has_host ( ) {
1634
1649
if SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
You can’t perform that action at this time.
0 commit comments