Skip to content

UpdatePort corrupts the host when port digits appear inside the host/IP #753

Description

@SergoRoberto

Description

URL.UpdatePort rewrites the port using strings.Replace on the whole host string,
replacing the first match of the port digits instead of the actual port segment.
If the same digits occur inside the IP/hostname, the wrong part gets modified.

Steps to reproduce

u, _ := urlutil.Parse("http://37.228.93.80:80/")
u.UpdatePort("443")
fmt.Println(u.String())

Expected

http://37.228.93.80:443/

Actual

http://37.228.93.8043:80/

Same issue with IPv6, e.g. http://[2001:db8::80]:80/.

Environment

  • package: github.com/projectdiscovery/utils/url

PR

#752

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions