diff options
Diffstat (limited to 'src/WixToolset.Core/Compiler.cs')
-rw-r--r-- | src/WixToolset.Core/Compiler.cs | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs index b29821b0..020e35fe 100644 --- a/src/WixToolset.Core/Compiler.cs +++ b/src/WixToolset.Core/Compiler.cs | |||
@@ -9,7 +9,6 @@ namespace WixToolset.Core | |||
9 | using System.Globalization; | 9 | using System.Globalization; |
10 | using System.IO; | 10 | using System.IO; |
11 | using System.Linq; | 11 | using System.Linq; |
12 | using System.Text.RegularExpressions; | ||
13 | using System.Xml.Linq; | 12 | using System.Xml.Linq; |
14 | using WixToolset.Data; | 13 | using WixToolset.Data; |
15 | using WixToolset.Data.Symbols; | 14 | using WixToolset.Data.Symbols; |
@@ -26,8 +25,8 @@ namespace WixToolset.Core | |||
26 | private const int MinValueOfMaxCabSizeForLargeFileSplitting = 20; // 20 MB | 25 | private const int MinValueOfMaxCabSizeForLargeFileSplitting = 20; // 20 MB |
27 | private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) | 26 | private const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) |
28 | 27 | ||
29 | private const string DefaultComponentIdPlaceholderFormat = "WixComponentIdPlaceholder{0}"; | 28 | private const string DefaultComponentIdPlaceholderPrefix = "WixComponentIdPlaceholder"; |
30 | private const string DefaultComponentIdPlaceholderWixVariableFormat = "!(wix.{0})"; | 29 | private const string DefaultComponentIdPlaceholderWixVariablePrefix = "!(wix."; |
31 | // If these are true you know you are building a module or product | 30 | // If these are true you know you are building a module or product |
32 | // but if they are false you cannot not be sure they will not end | 31 | // but if they are false you cannot not be sure they will not end |
33 | // up a product or module. Use these flags carefully. | 32 | // up a product or module. Use these flags carefully. |
@@ -342,16 +341,22 @@ namespace WixToolset.Core | |||
342 | 341 | ||
343 | if (!String.IsNullOrEmpty(value)) | 342 | if (!String.IsNullOrEmpty(value)) |
344 | { | 343 | { |
345 | var regex = new Regex(@"\[(?<identifier>[a-zA-Z_][a-zA-Z0-9_\.]*)]", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.ExplicitCapture); | 344 | var start = value.IndexOf('['); |
346 | var matches = regex.Matches(value); | 345 | while (start != -1 && start < value.Length) |
347 | |||
348 | foreach (Match match in matches) | ||
349 | { | 346 | { |
350 | var group = match.Groups["identifier"]; | 347 | var end = value.IndexOf(']', start + 1); |
351 | if (group.Success) | 348 | if (end == -1) |
349 | { | ||
350 | break; | ||
351 | } | ||
352 | |||
353 | var id = value.Substring(start + 1, end - 1); | ||
354 | if (Common.IsIdentifier(id)) | ||
352 | { | 355 | { |
353 | this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, propertyId.Id, group.Value)); | 356 | this.Core.Write(WarningMessages.PropertyValueContainsPropertyReference(sourceLineNumbers, propertyId.Id, id)); |
354 | } | 357 | } |
358 | |||
359 | start = (end < value.Length) ? value.IndexOf('[', end + 1) : -1; | ||
355 | } | 360 | } |
356 | } | 361 | } |
357 | 362 | ||
@@ -2091,8 +2096,8 @@ namespace WixToolset.Core | |||
2091 | var encounteredODBCDataSource = false; | 2096 | var encounteredODBCDataSource = false; |
2092 | var files = 0; | 2097 | var files = 0; |
2093 | var guid = "*"; | 2098 | var guid = "*"; |
2094 | var componentIdPlaceholder = String.Format(Compiler.DefaultComponentIdPlaceholderFormat, this.componentIdPlaceholdersResolver.VariableCount); // placeholder id for defaulting Component/@Id to keypath id. | 2099 | var componentIdPlaceholder = Compiler.DefaultComponentIdPlaceholderPrefix + this.componentIdPlaceholdersResolver.VariableCount; // placeholder id for defaulting Component/@Id to keypath id. |
2095 | var componentIdPlaceholderWixVariable = String.Format(Compiler.DefaultComponentIdPlaceholderWixVariableFormat, componentIdPlaceholder); | 2100 | var componentIdPlaceholderWixVariable = Compiler.DefaultComponentIdPlaceholderWixVariablePrefix + componentIdPlaceholder + ")"; |
2096 | var id = new Identifier(AccessModifier.Private, componentIdPlaceholderWixVariable); | 2101 | var id = new Identifier(AccessModifier.Private, componentIdPlaceholderWixVariable); |
2097 | var keyFound = false; | 2102 | var keyFound = false; |
2098 | string keyPath = null; | 2103 | string keyPath = null; |
@@ -4080,7 +4085,7 @@ namespace WixToolset.Core | |||
4080 | break; | 4085 | break; |
4081 | case "Name": | 4086 | case "Name": |
4082 | nameHasValue = true; | 4087 | nameHasValue = true; |
4083 | if (attrib.Value.Equals(".")) | 4088 | if (attrib.Value == ".") |
4084 | { | 4089 | { |
4085 | name = attrib.Value; | 4090 | name = attrib.Value; |
4086 | } | 4091 | } |
@@ -4225,7 +4230,7 @@ namespace WixToolset.Core | |||
4225 | defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName)); | 4230 | defaultDir = String.Concat(defaultDir, ":", String.IsNullOrEmpty(shortSourceName) ? sourceName : String.Concat(shortSourceName, "|", sourceName)); |
4226 | } | 4231 | } |
4227 | 4232 | ||
4228 | if ("TARGETDIR".Equals(id.Id) && !"SourceDir".Equals(defaultDir)) | 4233 | if ("TARGETDIR".Equals(id.Id, StringComparison.Ordinal) && !"SourceDir".Equals(defaultDir, StringComparison.Ordinal)) |
4229 | { | 4234 | { |
4230 | this.Core.Write(ErrorMessages.IllegalTargetDirDefaultDir(sourceLineNumbers, defaultDir)); | 4235 | this.Core.Write(ErrorMessages.IllegalTargetDirDefaultDir(sourceLineNumbers, defaultDir)); |
4231 | } | 4236 | } |
@@ -7147,13 +7152,9 @@ namespace WixToolset.Core | |||
7147 | else // external cabinet file | 7152 | else // external cabinet file |
7148 | { | 7153 | { |
7149 | // external cabinet files must use 8.3 filenames | 7154 | // external cabinet files must use 8.3 filenames |
7150 | if (!String.IsNullOrEmpty(cabinet) && !this.Core.IsValidShortFilename(cabinet, false)) | 7155 | if (!String.IsNullOrEmpty(cabinet) && !this.Core.IsValidLongFilename(cabinet) && !Common.ContainsValidBinderVariable(cabinet)) |
7151 | { | 7156 | { |
7152 | // WiX variables in the name will trip the "not a valid 8.3 name" switch, so let them through | 7157 | this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "Cabinet", cabinet)); |
7153 | if (!Common.WixVariableRegex.Match(cabinet).Success) | ||
7154 | { | ||
7155 | this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "Cabinet", cabinet)); | ||
7156 | } | ||
7157 | } | 7158 | } |
7158 | } | 7159 | } |
7159 | } | 7160 | } |
@@ -7286,12 +7287,12 @@ namespace WixToolset.Core | |||
7286 | if (!this.Core.IsValidLocIdentifier(exampleCabinetName)) | 7287 | if (!this.Core.IsValidLocIdentifier(exampleCabinetName)) |
7287 | { | 7288 | { |
7288 | // The example name should not match the authored template since that would nullify the | 7289 | // The example name should not match the authored template since that would nullify the |
7289 | // reason for having multiple cabients. External cabinet files must also be valid file names. | 7290 | // reason for having multiple cabinets. External cabinet files must also be valid file names. |
7290 | if (exampleCabinetName.Equals(authoredCabinetTemplateValue) || !this.Core.IsValidLongFilename(exampleCabinetName, false)) | 7291 | if (exampleCabinetName.Equals(authoredCabinetTemplateValue, StringComparison.OrdinalIgnoreCase) || !this.Core.IsValidLongFilename(exampleCabinetName, false)) |
7291 | { | 7292 | { |
7292 | this.Core.Write(ErrorMessages.InvalidCabinetTemplate(sourceLineNumbers, cabinetTemplate)); | 7293 | this.Core.Write(ErrorMessages.InvalidCabinetTemplate(sourceLineNumbers, cabinetTemplate)); |
7293 | } | 7294 | } |
7294 | else if (!this.Core.IsValidShortFilename(exampleCabinetName, false) && !Common.WixVariableRegex.Match(exampleCabinetName).Success) // ignore short names with wix variables because it rarely works out. | 7295 | else if (!this.Core.IsValidLongFilename(exampleCabinetName) && !Common.ContainsValidBinderVariable(exampleCabinetName)) // ignore short names with wix variables because it rarely works out. |
7295 | { | 7296 | { |
7296 | this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "CabinetTemplate", cabinetTemplate)); | 7297 | this.Core.Write(WarningMessages.MediaExternalCabinetFilenameIllegal(sourceLineNumbers, node.Name.LocalName, "CabinetTemplate", cabinetTemplate)); |
7297 | } | 7298 | } |