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
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
Description
URL.UpdatePortrewrites the port usingstrings.Replaceon 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
Expected
Actual
Same issue with IPv6, e.g.
http://[2001:db8::80]:80/.Environment
github.com/projectdiscovery/utils/urlPR
#752