Skip to content

Commit

Permalink
Introduce early exception for overlength Windows Installer table name
Browse files Browse the repository at this point in the history
Signed-off-by: Bevan Weiss <[email protected]>
  • Loading branch information
bevanweiss committed Sep 29, 2024
1 parent ce73352 commit fb8189e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/api/wix/WixToolset.Data/ErrorMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,11 @@ public static Message IllegalAttributeWhenNested(SourceLineNumber sourceLineNumb
return Message(sourceLineNumbers, Ids.IllegalAttributeWhenNested, "The File element contains an attribute '{0}' that cannot be used in a File element that is a child of a Component element.", attributeName);
}

public static Message OverlengthTableNameInProductOrMergeModule(SourceLineNumber sourceLineNumbers, string tableName)
{
return Message(sourceLineNumbers, Ids.OverlengthTableNameInProductOrMergeModule, "The table name '{0}' is invalid because the table name exceeds 31 characters in length. For more information, see: https://learn.microsoft.com/en-au/windows/win32/msi/table-names", tableName);
}

private static Message Message(SourceLineNumber sourceLineNumber, Ids id, string format, params object[] args)
{
return new Message(sourceLineNumber, MessageLevel.Error, (int)id, format, args);
Expand All @@ -2276,6 +2281,8 @@ private static Message Message(SourceLineNumber sourceLineNumber, Ids id, Resour
return new Message(sourceLineNumber, MessageLevel.Error, (int)id, resourceManager, resourceName, args);
}



public enum Ids
{
UnexpectedException = 1,
Expand Down Expand Up @@ -2667,6 +2674,7 @@ public enum Ids
MsiTransactionInvalidPackage2 = 412,
ExpectedAttributeOrElementWithOtherAttribute = 413,
ExpectedAttributeOrElementWithoutOtherAttribute = 414,
OverlengthTableNameInProductOrMergeModule = 415
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,14 @@ private void ReportIllegalTables()
this.Messaging.Write(WarningMessages.DangerousTableInMergeModule(row.SourceLineNumbers, table.Name));
}
}

if (31 < table.Name.Length)
{
foreach (var row in table.Rows)
{
this.Messaging.Write(ErrorMessages.OverlengthTableNameInProductOrMergeModule(row.SourceLineNumbers, table.Name));
}
}
break;

case OutputType.PatchCreation:
Expand Down Expand Up @@ -1506,6 +1514,13 @@ private void ReportIllegalTables()
this.Messaging.Write(WarningMessages.UnexpectedTableInProduct(row.SourceLineNumbers, table.Name));
}
}
if (31 < table.Name.Length)
{
foreach (var row in table.Rows)
{
this.Messaging.Write(ErrorMessages.OverlengthTableNameInProductOrMergeModule(row.SourceLineNumbers, table.Name));
}
}
break;
}
}
Expand Down

0 comments on commit fb8189e

Please sign in to comment.