Skip to content

Commit

Permalink
FIX - NullReferenceException caused by bad langtag #387
Browse files Browse the repository at this point in the history
  • Loading branch information
turquoiseowl committed Aug 14, 2019
1 parent a76406e commit c418e33
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/i18n/Concrete/TextLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ private bool IsLanguageValid(string langtag)
{
// Note that there is no need to serialize access to System.Web.HttpRuntime.Cache when just reading from it.
//
if (!langtag.IsSet()) {
return false; }

// Default language is always valid.
if (LocalizedApplication.Current.MessageKeyIsValueInDefaultLanguage
&& LocalizedApplication.Current.DefaultLanguageTag.Equals(langtag)) {
Expand Down
6 changes: 4 additions & 2 deletions src/i18n/LocalizedApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,12 @@ public string DefaultLanguage
}
set
{
DefaultLanguageTag = LanguageTag.GetCachedInstance(value);
LanguageTag defaultLanguageTag = LanguageTag.GetCachedInstance(value);
if (defaultLanguageTag != null) {
DefaultLanguageTag = defaultLanguageTag; }
}
}
public LanguageTag DefaultLanguageTag { get; set; }
public LanguageTag DefaultLanguageTag { get; private set; }

/// <summary>
/// Specifies whether the key for a message may be assumed to be the value for
Expand Down

0 comments on commit c418e33

Please sign in to comment.