diff options
| author | Sean Hall <r.sean.hall@gmail.com> | 2022-08-01 17:07:49 -0500 |
|---|---|---|
| committer | Sean Hall <r.sean.hall@gmail.com> | 2022-08-02 09:15:14 -0500 |
| commit | 28c8abfda013d6aa568fde8b26da65522748d376 (patch) | |
| tree | b2e98b0e69e2941c659979f7b2bedff5a0a29b4f /src/api | |
| parent | aacd6b677332f2e262d0df67603c246cd65d833e (diff) | |
| download | wix-28c8abfda013d6aa568fde8b26da65522748d376.tar.gz wix-28c8abfda013d6aa568fde8b26da65522748d376.tar.bz2 wix-28c8abfda013d6aa568fde8b26da65522748d376.zip | |
Downgrade error to warning when search refs a reserved prefix variable.
The engine doesn't actually prevent external callers from setting variables that start with 'Wix'.
Diffstat (limited to 'src/api')
3 files changed, 58 insertions, 4 deletions
diff --git a/src/api/wix/WixToolset.Extensibility/Data/BundleVariableNameRule.cs b/src/api/wix/WixToolset.Extensibility/Data/BundleVariableNameRule.cs new file mode 100644 index 00000000..eb6f7543 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/BundleVariableNameRule.cs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. | ||
| 2 | |||
| 3 | namespace WixToolset.Extensibility.Data | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | |||
| 7 | /// <summary> | ||
| 8 | /// When validating a bundle variable name, which special restrictions to ignore. | ||
| 9 | /// </summary> | ||
| 10 | [Flags] | ||
| 11 | public enum BundleVariableNameRule | ||
| 12 | { | ||
| 13 | /// <summary> | ||
| 14 | /// Enforce all special restrictions. | ||
| 15 | /// </summary> | ||
| 16 | EnforceAllRestrictions = 0x0, | ||
| 17 | |||
| 18 | /// <summary> | ||
| 19 | /// Allow names of built-in variables. | ||
| 20 | /// </summary> | ||
| 21 | CanBeBuiltIn = 0x1, | ||
| 22 | |||
| 23 | /// <summary> | ||
| 24 | /// Allow names of well-known variables. | ||
| 25 | /// </summary> | ||
| 26 | CanBeWellKnown = 0x2, | ||
| 27 | |||
| 28 | /// <summary> | ||
| 29 | /// Allow names that are not built-in and are not well-known and start with 'Wix'. | ||
| 30 | /// </summary> | ||
| 31 | CanHaveReservedPrefix = 0x4, | ||
| 32 | } | ||
| 33 | } | ||
diff --git a/src/api/wix/WixToolset.Extensibility/Services/IBundleValidator.cs b/src/api/wix/WixToolset.Extensibility/Services/IBundleValidator.cs index 43f65fc8..3753d16d 100644 --- a/src/api/wix/WixToolset.Extensibility/Services/IBundleValidator.cs +++ b/src/api/wix/WixToolset.Extensibility/Services/IBundleValidator.cs | |||
| @@ -33,15 +33,35 @@ namespace WixToolset.Extensibility.Services | |||
| 33 | bool ValidateBundleMsiPropertyName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string propertyName); | 33 | bool ValidateBundleMsiPropertyName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string propertyName); |
| 34 | 34 | ||
| 35 | /// <summary> | 35 | /// <summary> |
| 36 | /// Validates a Bundle variable name and displays an error for an illegal value. | 36 | /// Validates a Bundle variable name that is being used to declare a Variable in the bundle manifest and displays an error for an illegal value. |
| 37 | /// </summary> | 37 | /// </summary> |
| 38 | /// <param name="sourceLineNumbers"></param> | 38 | /// <param name="sourceLineNumbers"></param> |
| 39 | /// <param name="elementName"></param> | 39 | /// <param name="elementName"></param> |
| 40 | /// <param name="attributeName"></param> | 40 | /// <param name="attributeName"></param> |
| 41 | /// <param name="variableName"></param> | 41 | /// <param name="variableName"></param> |
| 42 | /// <param name="allowBuiltIn">Whether to bypass checks for reserved values.</param> | ||
| 43 | /// <returns>Whether the name is valid.</returns> | 42 | /// <returns>Whether the name is valid.</returns> |
| 44 | bool ValidateBundleVariableName(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, bool allowBuiltIn); | 43 | bool ValidateBundleVariableNameDeclaration(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName); |
| 44 | |||
| 45 | /// <summary> | ||
| 46 | /// Validates a Bundle variable name that is being used to reference a Variable and displays an error for an illegal value. | ||
| 47 | /// </summary> | ||
| 48 | /// <param name="sourceLineNumbers"></param> | ||
| 49 | /// <param name="elementName"></param> | ||
| 50 | /// <param name="attributeName"></param> | ||
| 51 | /// <param name="variableName"></param> | ||
| 52 | /// <param name="nameRule"></param> | ||
| 53 | /// <returns>Whether the name is valid.</returns> | ||
| 54 | bool ValidateBundleVariableNameValue(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName, BundleVariableNameRule nameRule); | ||
| 55 | |||
| 56 | /// <summary> | ||
| 57 | /// Validates a Bundle variable name that is being used to set its value and displays an error for an illegal value. | ||
| 58 | /// </summary> | ||
| 59 | /// <param name="sourceLineNumbers"></param> | ||
| 60 | /// <param name="elementName"></param> | ||
| 61 | /// <param name="attributeName"></param> | ||
| 62 | /// <param name="variableName"></param> | ||
| 63 | /// <returns>Whether the name is valid.</returns> | ||
| 64 | bool ValidateBundleVariableNameTarget(SourceLineNumber sourceLineNumbers, string elementName, string attributeName, string variableName); | ||
| 45 | 65 | ||
| 46 | /// <summary> | 66 | /// <summary> |
| 47 | /// Validates a bundle condition and displays an error for an illegal value. | 67 | /// Validates a bundle condition and displays an error for an illegal value. |
diff --git a/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs b/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs index a8246b9b..3a3c2ceb 100644 --- a/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs +++ b/src/api/wix/WixToolset.Extensibility/Services/IParseHelper.cs | |||
| @@ -246,8 +246,9 @@ namespace WixToolset.Extensibility.Services | |||
| 246 | /// </summary> | 246 | /// </summary> |
| 247 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> | 247 | /// <param name="sourceLineNumbers">Source line information about the owner element.</param> |
| 248 | /// <param name="attribute">The attribute containing the value to get.</param> | 248 | /// <param name="attribute">The attribute containing the value to get.</param> |
| 249 | /// <param name="nameRule">A rule for the contents of the value. If the contents do not follow the rule, an error is thrown.</param> | ||
| 249 | /// <returns>The attribute's value.</returns> | 250 | /// <returns>The attribute's value.</returns> |
| 250 | string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute); | 251 | string GetAttributeBundleVariableNameValue(SourceLineNumber sourceLineNumbers, XAttribute attribute, BundleVariableNameRule nameRule = BundleVariableNameRule.CanBeWellKnown | BundleVariableNameRule.CanHaveReservedPrefix); |
| 251 | 252 | ||
| 252 | /// <summary> | 253 | /// <summary> |
| 253 | /// Get a guid attribute value and displays an error for an illegal guid value. | 254 | /// Get a guid attribute value and displays an error for an illegal guid value. |
