mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2025-12-20 00:50:06 +08:00
fix: compare authentication scheme case-insensitively (#2386)
This commit is contained in:
parent
140d892ccf
commit
438d4138d6
@ -63,7 +63,11 @@ func removeExtraHTTPHostPort(req *http.Request) {
|
|||||||
// parseBasicProxyAuthorization parse header Proxy-Authorization and return base64-encoded credential
|
// parseBasicProxyAuthorization parse header Proxy-Authorization and return base64-encoded credential
|
||||||
func parseBasicProxyAuthorization(request *http.Request) string {
|
func parseBasicProxyAuthorization(request *http.Request) string {
|
||||||
value := request.Header.Get("Proxy-Authorization")
|
value := request.Header.Get("Proxy-Authorization")
|
||||||
if !strings.HasPrefix(value, "Basic ") {
|
const prefix = "Basic "
|
||||||
|
// According to RFC7617, the scheme should be case-insensitive.
|
||||||
|
// In practice, some implementations do use different case styles, causing authentication to fail
|
||||||
|
// eg: https://github.com/algesten/ureq/blob/381fd42cfcb80a5eb709d64860aa0ae726f17b8e/src/unversioned/transport/connect.rs#L118
|
||||||
|
if len(value) < len(prefix) || !strings.EqualFold(value[:len(prefix)], prefix) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user