Skip to content

Do not treat a port colon as a password after set_host("") - #1184

Open
kevin9327 wants to merge 1 commit into
servo:mainfrom
kevin9327:fix-password-after-empty-host
Open

kevin9327 wants to merge 1 commit into
servo:mainfrom
kevin9327:fix-password-after-empty-host

Conversation

@kevin9327

Copy link
Copy Markdown

Calling set_host(Some(\"\")) on a non-special URL such as sc://test:12/ is allowed and can produce sc://:12/. password() then treated the port : as a password separator, because it assumed a host cannot be empty, and panicked with an inverted slice range (byte range starts at 6 but ends at 4).

The method now requires the userinfo to be terminated by @ before taking a password slice, so password() returns None for sc://:12/ and still returns the password when @ is present.

Fixes #1174

password() assumed a ':' at username_end could not be a port because
the host cannot be empty. set_host("") is allowed on non-special URLs
and can leave a serialization such as sc://:12/, so that colon is the
port and the old slice was inverted.

Require a terminating '@' before treating the colon as a password
separator.

Fixes servo#1174

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invalid slice range on password() after set_host("")

1 participant