cfssl
cfssl copied to clipboard
Replace normalizeURL with urlx.Parse
normalizeURL used to break URLs with path by rewriting their host part and it would also panic on "IP:Port" strings.
I've refactored that to utilize urlx.Parse and also added a couple of test cases.
normalizeURL used to break URLs with path by rewriting their host part
Do you have an example / test-case that would show the URLs that would break? This is adding 8K lines of code (as dependency) to parse an URL, which seems a lot for just this, so wondering if the problem could be solved in another way.
normalizeURL used to break URLs with path by rewriting their host part
Do you have an example / test-case that would show the URLs that would break? This is adding 8K lines of code (as dependency) to parse an URL, which seems a lot for just this, so wondering if the problem could be solved in another way.
Given this was some time ago I'm no longer sure but I strongly suppose I put them in the tests.
Thanks! I think the reason url.Parse()
may fail for some of those is that, if no scheme is provided, some results may be ambiguous.
The code I tried above avoids that situation by checking if a scheme is present and if not, to prepend the default scheme;
if strings.Index(addr, "://") == -1 {
// use http:// if no scheme is provided
addr = "http://" + addr
}
Of course it's possible that urlx handles more esoteric cases besides those, but (and I'm not a maintainer, just a passer-by! 😅) I wonder if that's enough to warrant the larger number of lines imported from the additional dependency.