From 8181317ba1b9f718b6e54ce13cba04351e464c01 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 27 Jun 2020 14:06:52 -0700 Subject: Remove use of RemoteAddress inner text --- .../TestData/UsingFirewall/PackageComponents.wxs | 2 +- .../UsingOutboundFirewall/PackageComponents.wxs | 2 +- src/wixext/FirewallCompiler.cs | 11 ++-- src/wixext/FirewallErrors.cs | 6 --- src/wixext/firewall.xsd | 58 +++++++++++----------- 5 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs index 910cca2d..53e75427 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingFirewall/PackageComponents.wxs @@ -6,7 +6,7 @@ - * + diff --git a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs index f8c1e781..8084706e 100644 --- a/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs +++ b/src/test/WixToolsetTest.Firewall/TestData/UsingOutboundFirewall/PackageComponents.wxs @@ -6,7 +6,7 @@ - * + diff --git a/src/wixext/FirewallCompiler.cs b/src/wixext/FirewallCompiler.cs index aefc7f2c..e3cf201b 100644 --- a/src/wixext/FirewallCompiler.cs +++ b/src/wixext/FirewallCompiler.cs @@ -312,13 +312,19 @@ namespace WixToolset.Firewall private void ParseRemoteAddressElement(Intermediate intermediate, IntermediateSection section, XElement element, ref string remoteAddresses) { var sourceLineNumbers = this.ParseHelper.GetSourceLineNumbers(element); + string address = null; // no attributes foreach (var attrib in element.Attributes()) { if (String.IsNullOrEmpty(attrib.Name.NamespaceName) || this.Namespace == attrib.Name.Namespace) { - this.ParseHelper.UnexpectedAttribute(element, attrib); + switch (attrib.Name.LocalName) + { + case "Value": + address = this.ParseHelper.GetAttributeValue(sourceLineNumbers, attrib); + break; + } } else { @@ -328,10 +334,9 @@ namespace WixToolset.Firewall this.ParseHelper.ParseForExtensionElements(this.Context.Extensions, intermediate, section, element); - var address = this.ParseHelper.GetTrimmedInnerText(element); if (String.IsNullOrEmpty(address)) { - this.Messaging.Write(FirewallErrors.IllegalEmptyRemoteAddress(sourceLineNumbers)); + this.Messaging.Write(ErrorMessages.ExpectedAttribute(sourceLineNumbers, element.Name.LocalName, "Value")); } else { diff --git a/src/wixext/FirewallErrors.cs b/src/wixext/FirewallErrors.cs index 3fff8c8d..b2dac782 100644 --- a/src/wixext/FirewallErrors.cs +++ b/src/wixext/FirewallErrors.cs @@ -12,11 +12,6 @@ namespace WixToolset.Firewall return Message(sourceLineNumbers, Ids.IllegalRemoteAddressWithScopeAttribute, "The RemoteAddress element cannot be specified because its parent FirewallException already specified the Scope attribute. To use RemoteAddress elements, omit the Scope attribute."); } - public static Message IllegalEmptyRemoteAddress(SourceLineNumber sourceLineNumbers) - { - return Message(sourceLineNumbers, Ids.IllegalEmptyRemoteAddress, "The RemoteAddress element's inner text cannot be an empty string or completely whitespace."); - } - public static Message NoExceptionSpecified(SourceLineNumber sourceLineNumbers) { return Message(sourceLineNumbers, Ids.NoExceptionSpecified, "The FirewallException element doesn't identify the target of the firewall exception. To create an application exception, nest the FirewallException element under a File element or provide a value for the File or Program attributes. To create a port exception, provide a value for the Port attribute."); @@ -35,7 +30,6 @@ namespace WixToolset.Firewall public enum Ids { IllegalRemoteAddressWithScopeAttribute = 6401, - IllegalEmptyRemoteAddress = 6402, NoExceptionSpecified = 6403, } } diff --git a/src/wixext/firewall.xsd b/src/wixext/firewall.xsd index fec7e37a..20ad065f 100644 --- a/src/wixext/firewall.xsd +++ b/src/wixext/firewall.xsd @@ -33,7 +33,7 @@ - Explicitly-listed remote addresses that this exception allows through the + Explicitly-listed remote addresses that this exception allows through the firewall. @@ -51,7 +51,7 @@ - Name of this firewall exception, visible to the user in the firewall + Name of this firewall exception, visible to the user in the firewall control panel. @@ -63,7 +63,7 @@ The scope of this firewall exception, which indicates whether incoming connections can come from any computer including those on the Internet or only those on the local network subnet. To more precisely specify - allowed remote address, specify a custom scope using RemoteAddress + allowed remote address, specify a custom scope using RemoteAddress child elements. @@ -78,10 +78,10 @@ - Port to allow through the firewall for this exception. + Port to allow through the firewall for this exception. - If you use Port and also File or Program in the same - FirewallException element, the exception will fail to install on + If you use Port and also File or Program in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -91,11 +91,11 @@ - IP protocol used for this firewall exception. If Port is defined, - "tcp" is assumed if the protocol is not specified. + IP protocol used for this firewall exception. If Port is defined, + "tcp" is assumed if the protocol is not specified. - If you use Protocol and also File or Program in the same - FirewallException element, the exception will fail to install on + If you use Protocol and also File or Program in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -111,11 +111,11 @@ - Identifier of a file to be granted access to all incoming ports and + Identifier of a file to be granted access to all incoming ports and protocols. If you use File, you cannot also use Program. - If you use File and also Port or Protocol in the same - FirewallException element, the exception will fail to install on + If you use File and also Port or Protocol in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -125,13 +125,13 @@ - Path to a target program to be granted access to all incoming ports and - protocols. Note that this is a formatted field, so you can use [#fileId] - syntax to refer to a file being installed. If you use Program, you cannot + Path to a target program to be granted access to all incoming ports and + protocols. Note that this is a formatted field, so you can use [#fileId] + syntax to refer to a file being installed. If you use Program, you cannot also use File. - If you use Program and also Port or Protocol in the same - FirewallException element, the exception will fail to install on + If you use Program and also Port or Protocol in the same + FirewallException element, the exception will fail to install on Windows XP and Windows Server 2003. IgnoreFailure="yes" can be used to ignore the resulting failure, but the exception will not be added. @@ -141,7 +141,7 @@ - If "yes", failures to register this firewall exception will be silently + If "yes", failures to register this firewall exception will be silently ignored. If "no" (the default), failures will cause rollback. @@ -165,7 +165,7 @@ - Description for this firewall rule displayed in Windows Firewall manager in + Description for this firewall rule displayed in Windows Firewall manager in Windows Vista and later. @@ -184,26 +184,24 @@ - A remote address to which the port or program can listen. Address formats vary + A remote address to which the port or program can listen. Address formats vary based on the version of Windows and Windows Firewall the program is being installed on. For Windows XP SP2 and Windows Server 2003 SP1, see RemoteAddresses Property. For Windows Vista and Windows Server 2008, see - + RemoteAddresses Property. - - - - + + + A remote address. - - - - + + + -- cgit v1.2.3-55-g6feb