Skip to content

Commit ca88e8c

Browse files
Change usages of ToLower into ToLowerInvariant
This fixes a very hard-to-spot bug where Web3Auth & OpenLogin started to give various configuration errors on some specific devices. Here is where we reported it: https://web3auth.io/community/t/invalid-constructor-params-invalid-environment-settings/6643 It turns out all those devices were Turkish, and the character "ı" (or "dotless i" as non-Turkish people would say) was the reason. You see, in Turkish, lowercasing/uppercasing rules are different, because we have a distinction between "I" and "İ" where "I".ToLower() == "ı" and "İ".ToLower() == "i" which makes sense in Turkish, and "I".ToLower() == "i" makes sense for any other language, but obviously these two rules don't mix well. And ToLower() uses the current culture information of the device. Which can make network.ToString().ToLower() into "maınnet" and buildEnv.ToString() into "productıon" "stagıng" or "testıng". To sum up: ToLower uses current device's region settings for lowercasing a string, which can be different for some Turkic languages. ToLowerInvariant is what should be used where this behavior doesn't make sense.
1 parent 37b0d66 commit ca88e8c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Assets/Plugins/Web3AuthSDK/Web3Auth.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ public void Awake()
6262
this.initParams = new Dictionary<string, object>();
6363

6464
this.initParams["clientId"] = clientId;
65-
this.initParams["network"] = network.ToString().ToLower();
65+
this.initParams["network"] = network.ToString().ToLowerInvariant();
6666

6767
if (!string.IsNullOrEmpty(redirectUri))
6868
this.initParams["redirectUrl"] = redirectUri;
6969

7070
Application.deepLinkActivated += onDeepLinkActivated;
7171
if (!string.IsNullOrEmpty(Application.absoluteURL))
72-
onDeepLinkActivated(Application.absoluteURL);
72+
onDeepLinkActivated(Application.absoluteURL);C
7373

7474
#if UNITY_EDITOR
7575
Web3AuthSDK.Editor.Web3AuthDebug.onURLRecieved += (Uri url) =>
@@ -112,9 +112,9 @@ public void setOptions(Web3AuthOptions web3AuthOptions)
112112
this.initParams["clientId"] = this.web3AuthOptions.clientId;
113113

114114
if (this.web3AuthOptions.buildEnv != null)
115-
this.initParams["buildEnv"] = this.web3AuthOptions.buildEnv.ToString().ToLower();
115+
this.initParams["buildEnv"] = this.web3AuthOptions.buildEnv.ToString().ToLowerInvariant();
116116

117-
this.initParams["network"] = this.web3AuthOptions.network.ToString().ToLower();
117+
this.initParams["network"] = this.web3AuthOptions.network.ToString().ToLowerInvariant();
118118

119119
if (this.web3AuthOptions.useCoreKitKey.HasValue)
120120
this.initParams["useCoreKitKey"] = this.web3AuthOptions.useCoreKitKey.Value;

0 commit comments

Comments
 (0)