Skip to content

Commit

Permalink
[SimVarItem] Allow colon (:) in L var names (fixes #57); Validate tha…
Browse files Browse the repository at this point in the history
…t a unit type is specified for variable types which require them.
  • Loading branch information
mpaperno committed Aug 4, 2023
1 parent 5b8c4ad commit e98a251
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions MSFSTouchPortalPlugin/Types/SimVarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ static bool returnError(string err, ref string outerr) {
return returnError("Name is empty", ref resultMsg);
if (string.IsNullOrEmpty(SimVarName))
return returnError("Variable Name is empty", ref resultMsg);
if (RequiresUnitType(VariableType) && string.IsNullOrEmpty(Unit))
return returnError("Unit type is empty and required", ref resultMsg);

// Make sure a category is assigned, except for temporary items
if (CategoryId == Groups.None && DefinitionSource != SimVarDefinitionSource.Temporary)
Expand Down Expand Up @@ -466,8 +468,8 @@ static bool returnError(string err, ref string outerr) {

case 'L':
case 'T':
// Local and Token variable types may only have alphanumerics and underscores, no spaces.
if (!Regex.IsMatch(SimVarName, @"^[a-zA-Z][a-zA-Z0-9_]+$", RegexOptions.Compiled | RegexOptions.CultureInvariant))
// Local and Token variable types may only have alphanumerics, underscores, and colons; no spaces.
if (!Regex.IsMatch(SimVarName, @"^[a-zA-Z][a-zA-Z0-9_:]+$", RegexOptions.Compiled | RegexOptions.CultureInvariant))
return returnError($"Variable Name '{SimVarName}' contains invalid character(s)", ref resultMsg);
break;

Expand Down

0 comments on commit e98a251

Please sign in to comment.