aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2021-03-16 14:48:48 -0700
committerRob Mensching <rob@firegiant.com>2021-03-16 16:16:02 -0700
commit0b3381007cb201d5ee28aa80990cd14a1c376f18 (patch)
treeedf6910d3fa14c6a19d2c4490fa4b94739b9c4de /src
parent0d4df529a7e34f033112a1c6f16f749880334e7d (diff)
downloadwix-0b3381007cb201d5ee28aa80990cd14a1c376f18.tar.gz
wix-0b3381007cb201d5ee28aa80990cd14a1c376f18.tar.bz2
wix-0b3381007cb201d5ee28aa80990cd14a1c376f18.zip
Centralize disallow inner text handling in ParseHalper
Fixes wixtoolset/issues#6237
Diffstat (limited to 'src')
-rw-r--r--src/WixToolset.Core/Compiler.cs6
-rw-r--r--src/WixToolset.Core/CompilerCore.cs14
-rw-r--r--src/WixToolset.Core/Compiler_EmbeddedUI.cs4
-rw-r--r--src/WixToolset.Core/Compiler_Package.cs22
-rw-r--r--src/WixToolset.Core/Compiler_UI.cs10
-rw-r--r--src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs37
6 files changed, 48 insertions, 45 deletions
diff --git a/src/WixToolset.Core/Compiler.cs b/src/WixToolset.Core/Compiler.cs
index 22f0df8f..d751dde0 100644
--- a/src/WixToolset.Core/Compiler.cs
+++ b/src/WixToolset.Core/Compiler.cs
@@ -3399,8 +3399,6 @@ namespace WixToolset.Core
3399 win64 = true; 3399 win64 = true;
3400 } 3400 }
3401 3401
3402 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
3403
3404 // if we have an in-lined Script CustomAction ensure no source or target attributes were provided 3402 // if we have an in-lined Script CustomAction ensure no source or target attributes were provided
3405 if (inlineScript) 3403 if (inlineScript)
3406 { 3404 {
@@ -4125,7 +4123,7 @@ namespace WixToolset.Core
4125 } 4123 }
4126 } 4124 }
4127 4125
4128 this.Core.VerifyNoInnerText(sourceLineNumbers, node); 4126 this.Core.InnerTextDisallowed(node);
4129 4127
4130 if (null == columnName) 4128 if (null == columnName)
4131 { 4129 {
@@ -5365,8 +5363,6 @@ namespace WixToolset.Core
5365 } 5363 }
5366 } 5364 }
5367 5365
5368 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
5369
5370 if (CompilerConstants.IntegerNotSet == id) 5366 if (CompilerConstants.IntegerNotSet == id)
5371 { 5367 {
5372 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); 5368 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
diff --git a/src/WixToolset.Core/CompilerCore.cs b/src/WixToolset.Core/CompilerCore.cs
index ec22a8ec..d737b359 100644
--- a/src/WixToolset.Core/CompilerCore.cs
+++ b/src/WixToolset.Core/CompilerCore.cs
@@ -206,6 +206,11 @@ namespace WixToolset.Core
206 return false; 206 return false;
207 } 207 }
208 208
209 internal void InnerTextDisallowed(XElement element)
210 {
211 this.parseHelper.InnerTextDisallowed(element);
212 }
213
209 /// <summary> 214 /// <summary>
210 /// Verifies that a filename is ambiguous. 215 /// Verifies that a filename is ambiguous.
211 /// </summary> 216 /// </summary>
@@ -1103,15 +1108,6 @@ namespace WixToolset.Core
1103 return this.parseHelper.ScheduleActionSymbol(this.ActiveSection, sourceLineNumbers, access, sequence, actionName, condition, beforeAction, afterAction, overridable); 1108 return this.parseHelper.ScheduleActionSymbol(this.ActiveSection, sourceLineNumbers, access, sequence, actionName, condition, beforeAction, afterAction, overridable);
1104 } 1109 }
1105 1110
1106 internal void VerifyNoInnerText(SourceLineNumber sourceLineNumbers, XElement element)
1107 {
1108 var innerText = Common.GetInnerText(element);
1109 if (!String.IsNullOrWhiteSpace(innerText))
1110 {
1111 this.messaging.Write(ErrorMessages.IllegalInnerText(sourceLineNumbers, element.Name.LocalName, innerText));
1112 }
1113 }
1114
1115 private static string CreateValueList(ValueListKind kind, IEnumerable<string> values) 1111 private static string CreateValueList(ValueListKind kind, IEnumerable<string> values)
1116 { 1112 {
1117 // Ideally, we could denote the list kind (and the list itself) directly in the 1113 // Ideally, we could denote the list kind (and the list itself) directly in the
diff --git a/src/WixToolset.Core/Compiler_EmbeddedUI.cs b/src/WixToolset.Core/Compiler_EmbeddedUI.cs
index ca658962..ede03933 100644
--- a/src/WixToolset.Core/Compiler_EmbeddedUI.cs
+++ b/src/WixToolset.Core/Compiler_EmbeddedUI.cs
@@ -80,8 +80,6 @@ namespace WixToolset.Core
80 } 80 }
81 } 81 }
82 82
83 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
84
85 if (null == id) 83 if (null == id)
86 { 84 {
87 id = this.Core.CreateIdentifier("mec", source, type.ToString()); 85 id = this.Core.CreateIdentifier("mec", source, type.ToString());
@@ -92,6 +90,8 @@ namespace WixToolset.Core
92 this.Core.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "BinarySource", "FileSource", "PropertySource")); 90 this.Core.Write(ErrorMessages.ExpectedAttributes(sourceLineNumbers, node.Name.LocalName, "BinarySource", "FileSource", "PropertySource"));
93 } 91 }
94 92
93 this.Core.ParseForExtensionElements(node);
94
95 if (!this.Core.EncounteredError) 95 if (!this.Core.EncounteredError)
96 { 96 {
97 this.Core.AddSymbol(new MsiEmbeddedChainerSymbol(sourceLineNumbers, id) 97 this.Core.AddSymbol(new MsiEmbeddedChainerSymbol(sourceLineNumbers, id)
diff --git a/src/WixToolset.Core/Compiler_Package.cs b/src/WixToolset.Core/Compiler_Package.cs
index 1dac5399..dfd7d9e4 100644
--- a/src/WixToolset.Core/Compiler_Package.cs
+++ b/src/WixToolset.Core/Compiler_Package.cs
@@ -1157,8 +1157,6 @@ namespace WixToolset.Core
1157 } 1157 }
1158 } 1158 }
1159 1159
1160 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
1161
1162 if (null == sddl) 1160 if (null == sddl)
1163 { 1161 {
1164 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Sddl")); 1162 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Sddl"));
@@ -1447,8 +1445,6 @@ namespace WixToolset.Core
1447 this.Core.Write(ErrorMessages.CannotAuthorSpecialProperties(sourceLineNumbers, id.Id)); 1445 this.Core.Write(ErrorMessages.CannotAuthorSpecialProperties(sourceLineNumbers, id.Id));
1448 } 1446 }
1449 1447
1450 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
1451
1452 if ("ErrorDialog" == id.Id) 1448 if ("ErrorDialog" == id.Id)
1453 { 1449 {
1454 this.Core.CreateSimpleReference(sourceLineNumbers, SymbolDefinitions.Dialog, value); 1450 this.Core.CreateSimpleReference(sourceLineNumbers, SymbolDefinitions.Dialog, value);
@@ -1473,6 +1469,8 @@ namespace WixToolset.Core
1473 } 1469 }
1474 } 1470 }
1475 1471
1472 this.Core.InnerTextDisallowed(node);
1473
1476 // see if this property is used for appSearch 1474 // see if this property is used for appSearch
1477 var signatures = this.ParseSearchSignatures(node); 1475 var signatures = this.ParseSearchSignatures(node);
1478 1476
@@ -1986,8 +1984,6 @@ namespace WixToolset.Core
1986 } 1984 }
1987 } 1985 }
1988 1986
1989 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
1990
1991 this.Core.ParseForExtensionElements(node); 1987 this.Core.ParseForExtensionElements(node);
1992 1988
1993 return null == value ? multiStringValue ?? "[~]" : String.Concat(value, "[~]", multiStringValue); 1989 return null == value ? multiStringValue ?? "[~]" : String.Concat(value, "[~]", multiStringValue);
@@ -2547,8 +2543,6 @@ namespace WixToolset.Core
2547 } 2543 }
2548 } 2544 }
2549 2545
2550 this.Core.VerifyNoInnerText(childSourceLineNumbers, node);
2551
2552 if (customAction && "Custom" == actionName) 2546 if (customAction && "Custom" == actionName)
2553 { 2547 {
2554 this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Action")); 2548 this.Core.Write(ErrorMessages.ExpectedAttribute(childSourceLineNumbers, child.Name.LocalName, "Action"));
@@ -2637,6 +2631,8 @@ namespace WixToolset.Core
2637 } 2631 }
2638 } 2632 }
2639 } 2633 }
2634
2635 this.Core.InnerTextDisallowed(node);
2640 } 2636 }
2641 2637
2642 2638
@@ -3012,8 +3008,6 @@ namespace WixToolset.Core
3012 } 3008 }
3013 } 3009 }
3014 3010
3015 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
3016
3017 if (privilege == null) 3011 if (privilege == null)
3018 { 3012 {
3019 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name")); 3013 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Name"));
@@ -3375,8 +3369,6 @@ namespace WixToolset.Core
3375 } 3369 }
3376 } 3370 }
3377 3371
3378 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
3379
3380 if (argument == null) 3372 if (argument == null)
3381 { 3373 {
3382 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Value")); 3374 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Value"));
@@ -3715,8 +3707,6 @@ namespace WixToolset.Core
3715 } 3707 }
3716 } 3708 }
3717 3709
3718 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
3719
3720 if (null == id) 3710 if (null == id)
3721 { 3711 {
3722 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); 3712 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
@@ -3824,8 +3814,6 @@ namespace WixToolset.Core
3824 } 3814 }
3825 } 3815 }
3826 3816
3827 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
3828
3829 if (null == id) 3817 if (null == id)
3830 { 3818 {
3831 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id")); 3819 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Id"));
@@ -4304,8 +4292,6 @@ namespace WixToolset.Core
4304 } 4292 }
4305 } 4293 }
4306 4294
4307 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
4308
4309 if (String.IsNullOrEmpty(key)) 4295 if (String.IsNullOrEmpty(key))
4310 { 4296 {
4311 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key")); 4297 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Key"));
diff --git a/src/WixToolset.Core/Compiler_UI.cs b/src/WixToolset.Core/Compiler_UI.cs
index 5cc9b5a0..d712ec91 100644
--- a/src/WixToolset.Core/Compiler_UI.cs
+++ b/src/WixToolset.Core/Compiler_UI.cs
@@ -700,8 +700,6 @@ namespace WixToolset.Core
700 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Action")); 700 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Action"));
701 } 701 }
702 702
703 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
704
705 this.Core.ParseForExtensionElements(node); 703 this.Core.ParseForExtensionElements(node);
706 704
707 if (!this.Core.EncounteredError) 705 if (!this.Core.EncounteredError)
@@ -748,8 +746,6 @@ namespace WixToolset.Core
748 } 746 }
749 } 747 }
750 748
751 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
752
753 if (null == id) 749 if (null == id)
754 { 750 {
755 id = this.Core.CreateIdentifier("txt", text); 751 id = this.Core.CreateIdentifier("txt", text);
@@ -1425,7 +1421,7 @@ namespace WixToolset.Core
1425 } 1421 }
1426 } 1422 }
1427 1423
1428 this.Core.VerifyNoInnerText(sourceLineNumbers, node); 1424 this.Core.InnerTextDisallowed(child);
1429 1425
1430 if (!String.IsNullOrEmpty(text) && null != sourceFile) 1426 if (!String.IsNullOrEmpty(text) && null != sourceFile)
1431 { 1427 {
@@ -1443,6 +1439,8 @@ namespace WixToolset.Core
1443 } 1439 }
1444 } 1440 }
1445 1441
1442 this.Core.InnerTextDisallowed(node);
1443
1446 // If the radio buttons have icons, then we need to add the icon attribute. 1444 // If the radio buttons have icons, then we need to add the icon attribute.
1447 switch (radioButtonsType) 1445 switch (radioButtonsType)
1448 { 1446 {
@@ -1694,8 +1692,6 @@ namespace WixToolset.Core
1694 } 1692 }
1695 } 1693 }
1696 1694
1697 this.Core.VerifyNoInnerText(sourceLineNumbers, node);
1698
1699 if (null == control) 1695 if (null == control)
1700 { 1696 {
1701 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Control")); 1697 this.Core.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, node.Name.LocalName, "Control"));
diff --git a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
index 8e9f48c4..a9a0fa9d 100644
--- a/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
+++ b/src/WixToolset.Core/ExtensibilityServices/ParseHelper.cs
@@ -6,6 +6,8 @@ namespace WixToolset.Core.ExtensibilityServices
6 using System.Collections.Generic; 6 using System.Collections.Generic;
7 using System.Diagnostics; 7 using System.Diagnostics;
8 using System.Globalization; 8 using System.Globalization;
9 using System.Linq;
10 using System.Xml;
9 using System.Xml.Linq; 11 using System.Xml.Linq;
10 using WixToolset.Data; 12 using WixToolset.Data;
11 using WixToolset.Data.Symbols; 13 using WixToolset.Data.Symbols;
@@ -642,6 +644,19 @@ namespace WixToolset.Core.ExtensibilityServices
642 return value?.Trim(); 644 return value?.Trim();
643 } 645 }
644 646
647 public void InnerTextDisallowed(XElement element)
648 {
649 if (element.Nodes().Any(n => XmlNodeType.Text == n.NodeType || XmlNodeType.CDATA == n.NodeType))
650 {
651 var innerText = Common.GetInnerText(element);
652 if (!String.IsNullOrWhiteSpace(innerText))
653 {
654 var sourceLineNumbers = this.GetSourceLineNumbers(element);
655 this.Messaging.Write(ErrorMessages.IllegalInnerText(sourceLineNumbers, element.Name.LocalName, innerText));
656 }
657 }
658 }
659
645 public bool IsValidIdentifier(string value) 660 public bool IsValidIdentifier(string value)
646 { 661 {
647 return Common.IsIdentifier(value); 662 return Common.IsIdentifier(value);
@@ -714,17 +729,31 @@ namespace WixToolset.Core.ExtensibilityServices
714 729
715 public void ParseForExtensionElements(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element) 730 public void ParseForExtensionElements(IEnumerable<ICompilerExtension> extensions, Intermediate intermediate, IntermediateSection section, XElement element)
716 { 731 {
717 foreach (var child in element.Elements()) 732 var checkInnerText = false;
733
734 foreach (var child in element.Nodes())
718 { 735 {
719 if (element.Name.Namespace == child.Name.Namespace) 736 if (child is XElement childElement)
720 { 737 {
721 this.UnexpectedElement(element, child); 738 if (element.Name.Namespace == childElement.Name.Namespace)
739 {
740 this.UnexpectedElement(element, childElement);
741 }
742 else
743 {
744 this.ParseExtensionElement(extensions, intermediate, section, element, childElement);
745 }
722 } 746 }
723 else 747 else
724 { 748 {
725 this.ParseExtensionElement(extensions, intermediate, section, element, child); 749 checkInnerText = true;
726 } 750 }
727 } 751 }
752
753 if (checkInnerText)
754 {
755 this.InnerTextDisallowed(element);
756 }
728 } 757 }
729 758
730 public WixActionSymbol ScheduleActionSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string actionName, string condition, string beforeAction, string afterAction, bool overridable = false) 759 public WixActionSymbol ScheduleActionSymbol(IntermediateSection section, SourceLineNumber sourceLineNumbers, AccessModifier access, SequenceTable sequence, string actionName, string condition, string beforeAction, string afterAction, bool overridable = false)