Skip to content

Commit 012b11f

Browse files
Modify the "SetLanguage" function to prevent updating the language when the parameter "id" corresponds to a language that is not defined in the configuration file.
1 parent 9c70389 commit 012b11f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,7 +3459,7 @@ internal void SetSession(IGxSession value)
34593459

34603460
public int SetLanguage(string id)
34613461
{
3462-
if (Config.GetLanguageProperty(id, "code") != null)
3462+
if (Config.ValidLanguage(id))
34633463
{
34643464
SetProperty(GXLanguage, id);
34653465
_localUtil = GXResourceManager.GetLocalUtil(id);
@@ -3473,7 +3473,7 @@ public int SetLanguage(string id)
34733473
}
34743474
private int SetLanguageWithoutSession(string id)
34753475
{
3476-
if (Config.GetLanguageProperty(id, "code") != null)
3476+
if (Config.ValidLanguage(id))
34773477
{
34783478
SetContextProperty(GXLanguage, id);
34793479
_localUtil = GXResourceManager.GetLocalUtil(id);

dotnet/src/dotnetframework/GxClasses/Core/gxconfig.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,22 @@ public static string MapCustomError(string code)
280280
return null;
281281
}
282282
#endif
283+
internal static bool ValidLanguage(string language)
284+
{
285+
if (languages != null)
286+
return languages.Contains(language);
287+
else
288+
{
289+
#if NETCORE
290+
return false;
291+
#else
292+
#pragma warning disable CS0618 // Type or member is obsolete
293+
Hashtable appsettings = (Hashtable)ConfigurationSettings.GetConfig("languages/" + language);
294+
#pragma warning restore CS0618 // Type or member is obsolete
295+
return (appsettings != null);
296+
#endif
297+
}
298+
}
283299
public static string GetLanguageProperty(string language, string property)
284300
{
285301
string sString = null;

0 commit comments

Comments
 (0)