diff options
Diffstat (limited to 'src/WixToolset.Core/CompilerCore.cs')
| -rw-r--r-- | src/WixToolset.Core/CompilerCore.cs | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs index c2724f6b..2f65db7a 100644 --- a/src/WixToolset.Core/CompilerCore.cs +++ b/src/WixToolset.Core/CompilerCore.cs | |||
| @@ -10,7 +10,6 @@ namespace WixToolset.Core | |||
| 10 | using System.Globalization; | 10 | using System.Globalization; |
| 11 | using System.Reflection; | 11 | using System.Reflection; |
| 12 | using System.Text; | 12 | using System.Text; |
| 13 | using System.Text.RegularExpressions; | ||
| 14 | using System.Xml.Linq; | 13 | using System.Xml.Linq; |
| 15 | using WixToolset.Data; | 14 | using WixToolset.Data; |
| 16 | using WixToolset.Data.Symbols; | 15 | using WixToolset.Data.Symbols; |
| @@ -45,16 +44,8 @@ namespace WixToolset.Core | |||
| 45 | internal static readonly XNamespace W3SchemaPrefix = "http://www.w3.org/"; | 44 | internal static readonly XNamespace W3SchemaPrefix = "http://www.w3.org/"; |
| 46 | internal static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; | 45 | internal static readonly XNamespace WixNamespace = "http://wixtoolset.org/schemas/v4/wxs"; |
| 47 | 46 | ||
| 48 | private static readonly Regex AmbiguousFilename = new Regex(@"^.{6}\~\d", RegexOptions.Compiled); | ||
| 49 | |||
| 50 | private const string IllegalLongFilenameCharacters = @"[\\\?|><:/\*""]"; // illegal: \ ? | > < : / * " | ||
| 51 | private static readonly Regex IllegalLongFilename = new Regex(IllegalLongFilenameCharacters, RegexOptions.Compiled); | ||
| 52 | |||
| 53 | //public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB | ||
| 54 | |||
| 55 | |||
| 56 | // Built-in variables (from burn\engine\variable.cpp, "vrgBuiltInVariables", around line 113) | 47 | // Built-in variables (from burn\engine\variable.cpp, "vrgBuiltInVariables", around line 113) |
| 57 | private static readonly List<String> BuiltinBundleVariables = new List<string>( | 48 | private static readonly List<string> BuiltinBundleVariables = new List<string>( |
| 58 | new string[] { | 49 | new string[] { |
| 59 | "AdminToolsFolder", | 50 | "AdminToolsFolder", |
| 60 | "AppDataFolder", | 51 | "AppDataFolder", |
| @@ -221,7 +212,13 @@ namespace WixToolset.Core | |||
| 221 | /// <returns>true if the filename is ambiguous; false otherwise.</returns> | 212 | /// <returns>true if the filename is ambiguous; false otherwise.</returns> |
| 222 | public static bool IsAmbiguousFilename(string filename) | 213 | public static bool IsAmbiguousFilename(string filename) |
| 223 | { | 214 | { |
| 224 | return String.IsNullOrEmpty(filename) ? false : CompilerCore.AmbiguousFilename.IsMatch(filename); | 215 | if (String.IsNullOrEmpty(filename)) |
| 216 | { | ||
| 217 | return false; | ||
| 218 | } | ||
| 219 | |||
| 220 | var tilde = filename.IndexOf('~'); | ||
| 221 | return (tilde > 0 && tilde < filename.Length) && Char.IsNumber(filename[tilde + 1]); | ||
| 225 | } | 222 | } |
| 226 | 223 | ||
| 227 | /// <summary> | 224 | /// <summary> |
| @@ -273,9 +270,29 @@ namespace WixToolset.Core | |||
| 273 | /// <param name="filename">Filename to make valid.</param> | 270 | /// <param name="filename">Filename to make valid.</param> |
| 274 | /// <param name="replace">Replacement string for invalid characters in filename.</param> | 271 | /// <param name="replace">Replacement string for invalid characters in filename.</param> |
| 275 | /// <returns>Valid filename.</returns> | 272 | /// <returns>Valid filename.</returns> |
| 276 | public static string MakeValidLongFileName(string filename, string replace) | 273 | public static string MakeValidLongFileName(string filename, char replace) |
| 277 | { | 274 | { |
| 278 | return CompilerCore.IllegalLongFilename.Replace(filename, replace); | 275 | if (String.IsNullOrEmpty(filename)) |
| 276 | { | ||
| 277 | return filename; | ||
| 278 | } | ||
| 279 | |||
| 280 | StringBuilder sb = null; | ||
| 281 | |||
| 282 | var found = filename.IndexOfAny(Common.IllegalLongFilenameCharacters); | ||
| 283 | while (found != -1) | ||
| 284 | { | ||
| 285 | if (sb == null) | ||
| 286 | { | ||
| 287 | sb = new StringBuilder(filename); | ||
| 288 | } | ||
| 289 | |||
| 290 | sb[found] = replace; | ||
| 291 | |||
| 292 | found = (found + 1 < filename.Length) ? filename.IndexOfAny(Common.IllegalLongFilenameCharacters, found + 1) : -1; | ||
| 293 | } | ||
| 294 | |||
| 295 | return sb?.ToString() ?? filename; | ||
| 279 | } | 296 | } |
| 280 | 297 | ||
| 281 | /// <summary> | 298 | /// <summary> |
| @@ -717,7 +734,7 @@ namespace WixToolset.Core | |||
| 717 | throw new ArgumentNullException("attribute"); | 734 | throw new ArgumentNullException("attribute"); |
| 718 | } | 735 | } |
| 719 | 736 | ||
| 720 | string value = this.GetAttributeValue(sourceLineNumbers, attribute); | 737 | var value = this.GetAttributeValue(sourceLineNumbers, attribute); |
| 721 | 738 | ||
| 722 | if (0 < value.Length) | 739 | if (0 < value.Length) |
| 723 | { | 740 | { |
| @@ -1039,16 +1056,6 @@ namespace WixToolset.Core | |||
| 1039 | return this.parseHelper.ScheduleActionSymbol(this.ActiveSection, sourceLineNumbers, access, sequence, actionName, condition, beforeAction, afterAction, overridable); | 1056 | return this.parseHelper.ScheduleActionSymbol(this.ActiveSection, sourceLineNumbers, access, sequence, actionName, condition, beforeAction, afterAction, overridable); |
| 1040 | } | 1057 | } |
| 1041 | 1058 | ||
| 1042 | /// <summary> | ||
| 1043 | /// Finds a compiler extension by namespace URI. | ||
| 1044 | /// </summary> | ||
| 1045 | /// <param name="ns">Namespace the extension supports.</param> | ||
| 1046 | /// <returns>True if found compiler extension or false if nothing matches namespace URI.</returns> | ||
| 1047 | private bool TryFindExtension(XNamespace ns, out ICompilerExtension extension) | ||
| 1048 | { | ||
| 1049 | return this.extensions.TryGetValue(ns, out extension); | ||
| 1050 | } | ||
| 1051 | |||
| 1052 | private static string CreateValueList(ValueListKind kind, IEnumerable<string> values) | 1059 | private static string CreateValueList(ValueListKind kind, IEnumerable<string> values) |
| 1053 | { | 1060 | { |
| 1054 | // Ideally, we could denote the list kind (and the list itself) directly in the | 1061 | // Ideally, we could denote the list kind (and the list itself) directly in the |
