mirror of
https://github.com/lukaszraczylo/traefik-llmgateway.git
synced 2026-12-06 11:03:52 +00:00
fix(admin): scrub the re-serialised base URL from provider errors
sanitizeProviderErr now also replaces the URL as net/url writes it. A provider baseUrl with userinfo, a query or a fragment logs one construction warning. The config still loads.
This commit is contained in:
@@ -299,20 +299,24 @@ const unparseableBaseURLPlaceholder = "[unparseable url]"
|
||||
//
|
||||
// Still best-effort for URLs OTHER than rawBaseURL: an error naming a
|
||||
// redirect target is not caught. Rejecting a credential-bearing baseUrl
|
||||
// at construction (providers.go) is the only complete fix; this is the
|
||||
// containment that changes no behavior.
|
||||
// at construction (providers.go) would be the complete fix; instead the
|
||||
// constructor only warns, so a config that loads today keeps loading.
|
||||
func sanitizeProviderErr(lastErr, rawBaseURL string) string {
|
||||
if lastErr == "" || rawBaseURL == "" {
|
||||
return lastErr
|
||||
}
|
||||
out := replaceURLForm(lastErr, rawBaseURL)
|
||||
u, parseErr := url.Parse(rawBaseURL)
|
||||
if parseErr != nil || u.User == nil {
|
||||
if parseErr != nil {
|
||||
return out
|
||||
}
|
||||
// net/http reports url.URL.String(), which lower-cases the scheme and
|
||||
// re-escapes userinfo, so it can differ from the configured text.
|
||||
out = replaceURLForm(out, u.String())
|
||||
if u.User == nil {
|
||||
return out
|
||||
}
|
||||
if _, hasPassword := u.User.Password(); !hasPassword {
|
||||
// No password set means net/http passed the URL through
|
||||
// unmasked, so the verbatim pass above already matched it.
|
||||
return out
|
||||
}
|
||||
// net/http's exact stripPassword output, mirrored call for call.
|
||||
|
||||
Reference in New Issue
Block a user