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 @@ -1569,10 +1569,25 @@ impl Url {
1569
1569
if host == "" && SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
1570
1570
return Err ( ParseError :: EmptyHost ) ;
1571
1571
}
1572
+ let mut host_substr = host;
1573
+ // Otherwise, if c is U+003A (:) and the [] flag is unset, then
1574
+ if !host. starts_with ( '[' ) || !host. ends_with ( ']' ) {
1575
+ match host. find ( ':' ) {
1576
+ Some ( 0 ) => {
1577
+ // If buffer is the empty string, validation error, return failure.
1578
+ return Err ( ParseError :: InvalidDomainCharacter ) ;
1579
+ }
1580
+ // Let host be the result of host parsing buffer
1581
+ Some ( colon_index) => {
1582
+ host_substr = & host[ ..colon_index] ;
1583
+ }
1584
+ None => { }
1585
+ }
1586
+ }
1572
1587
if SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
1573
- self . set_host_internal ( Host :: parse ( host ) ?, None )
1588
+ self . set_host_internal ( Host :: parse ( host_substr ) ?, None ) ;
1574
1589
} else {
1575
- self . set_host_internal ( Host :: parse_opaque ( host ) ?, None )
1590
+ self . set_host_internal ( Host :: parse_opaque ( host_substr ) ?, None ) ;
1576
1591
}
1577
1592
} else if self . has_host ( ) {
1578
1593
if SchemeType :: from ( self . scheme ( ) ) . is_special ( ) {
You can’t perform that action at this time.
0 commit comments