[iOS 17] "Malformed URL" error is thrown when using UnityWebRequest with a URI containing "[]" (#12401)

Topic automatically created to discuss [iOS 17] “Malformed URL” error is thrown when using UnityWebRequest with a URI containing “[]”

We try encode result string for UnityWebRequest on iOS 17 and get error:
-1004 NSURLErrorDomain

source url:
familytown.playflock.com/familytown-ios/initV3?initLibrary=server_dev&viewer_id=66bf51b597a2bd5b864e4ca4&libraryList=[“ios_21_21”]&authvars={“locale”:“en”}

encoded url:
familytown.playflock.com%2Ffamilytown-ios%2FinitV3%3FinitLibrary%3Dserver_dev%26viewer_id%3D66bf51b597a2bd5b864e4ca4%26libraryList%3D%5B%22ios_21_21%22%5D%26authvars%3D%7B%22locale%22%3A%22en%22%7D

i have this problem in my adressables. Maybe someone will find my solution useful

static class AddressablesFixUrl
{
    //Register to override WebRequests Addressables creates to download
    [RuntimeInitializeOnLoadMethod]
    private static void Init()
    {
        Addressables.WebRequestOverride = EditWebRequestURL;
    }

    //Override the url of the WebRequest, the request passed to the method is what would be used as standard by Addressables.
    private static void EditWebRequestURL(UnityWebRequest request)
    {
        if (request.url.Contains('[') || request.url.Contains(']'))
        {
            string newUrl = request.url.Replace("[", "%5b").Replace("]", "%5d");
            request.url = newUrl;
        }
    }
}