aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2023-11-06 23:08:10 -0800
committerRob Mensching <rob@firegiant.com>2023-11-07 09:51:50 -0800
commit96e9c0f76029f27bd1f2a777aca385b29e9ec21a (patch)
treec283cfe4a82128d7dada190fd485c22e1c3f0956
parentb84202794f5fd4f21e0fb1fc74c2f5d531035db3 (diff)
downloadwix-96e9c0f76029f27bd1f2a777aca385b29e9ec21a.tar.gz
wix-96e9c0f76029f27bd1f2a777aca385b29e9ec21a.tar.bz2
wix-96e9c0f76029f27bd1f2a777aca385b29e9ec21a.zip
Avoid use of Encoding.WindowsCodePage
Fixes 7612
-rw-r--r--src/api/wix/WixToolset.Data/ErrorMessages.cs6
-rw-r--r--src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs2
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/EncodingFixture.cs44
-rw-r--r--src/wix/test/WixToolsetTest.CoreIntegration/TestData/Encoding/Encoding.wxs14
4 files changed, 62 insertions, 4 deletions
diff --git a/src/api/wix/WixToolset.Data/ErrorMessages.cs b/src/api/wix/WixToolset.Data/ErrorMessages.cs
index bc63247e..77433e6d 100644
--- a/src/api/wix/WixToolset.Data/ErrorMessages.cs
+++ b/src/api/wix/WixToolset.Data/ErrorMessages.cs
@@ -867,12 +867,12 @@ namespace WixToolset.Data
867 867
868 public static Message IllegalCodepage(int codepage) 868 public static Message IllegalCodepage(int codepage)
869 { 869 {
870 return Message(null, Ids.IllegalCodepage, "The code page '{0}' is not a valid Windows code page. Update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.", codepage); 870 return Message(null, Ids.IllegalCodepage, "The code page '{0}' is not a valid Windows code page. Update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.", codepage);
871 } 871 }
872 872
873 public static Message IllegalCodepage(SourceLineNumber sourceLineNumbers, int codepage) 873 public static Message IllegalCodepage(SourceLineNumber sourceLineNumbers, int codepage)
874 { 874 {
875 return Message(sourceLineNumbers, Ids.IllegalCodepage, "The code page '{0}' is not a valid Windows code page. Update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.", codepage); 875 return Message(sourceLineNumbers, Ids.IllegalCodepage, "The code page '{0}' is not a valid Windows code page. Update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.", codepage);
876 } 876 }
877 877
878 public static Message IllegalCodepageAttribute(SourceLineNumber sourceLineNumbers, string codepage, string elementName, string attributeName) 878 public static Message IllegalCodepageAttribute(SourceLineNumber sourceLineNumbers, string codepage, string elementName, string attributeName)
@@ -1318,7 +1318,7 @@ namespace WixToolset.Data
1318 1318
1319 public static Message InvalidStringForCodepage(SourceLineNumber sourceLineNumbers, string codepage) 1319 public static Message InvalidStringForCodepage(SourceLineNumber sourceLineNumbers, string codepage)
1320 { 1320 {
1321 return Message(sourceLineNumbers, Ids.InvalidStringForCodepage, "A string was provided with characters that are not available in the specified database code page '{0}'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, PatchCreation/@Codepage, or WixLocalization/@Codepage.", codepage); 1321 return Message(sourceLineNumbers, Ids.InvalidStringForCodepage, "A string was provided with characters that are not available in the specified database code page '{0}'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.", codepage);
1322 } 1322 }
1323 1323
1324 public static Message InvalidStubExe(string filename) 1324 public static Message InvalidStubExe(string filename)
diff --git a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs
index 89fc81db..28bcfd4a 100644
--- a/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs
+++ b/src/wix/WixToolset.Core.WindowsInstaller/Bind/CreateIdtFileCommand.cs
@@ -81,7 +81,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
81 } 81 }
82 catch (EncoderFallbackException) 82 catch (EncoderFallbackException)
83 { 83 {
84 this.Messaging.Write(ErrorMessages.InvalidStringForCodepage(row.SourceLineNumbers, Convert.ToString(writer.Encoding.WindowsCodePage, CultureInfo.InvariantCulture))); 84 this.Messaging.Write(ErrorMessages.InvalidStringForCodepage(row.SourceLineNumbers, Convert.ToString(writer.Encoding.CodePage, CultureInfo.InvariantCulture)));
85 85
86 rowBytes = convertEncoding.GetBytes(rowString); 86 rowBytes = convertEncoding.GetBytes(rowString);
87 } 87 }
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/EncodingFixture.cs b/src/wix/test/WixToolsetTest.CoreIntegration/EncodingFixture.cs
new file mode 100644
index 00000000..f02cba75
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/EncodingFixture.cs
@@ -0,0 +1,44 @@
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
3namespace WixToolsetTest.CoreIntegration
4{
5 using System.IO;
6 using System.Linq;
7 using WixInternal.Core.TestPackage;
8 using WixInternal.TestSupport;
9 using WixToolset.Data;
10 using Xunit;
11
12 public class EncodingFixture
13 {
14 [Fact]
15 public void PopulatesAppIdTableWhenAdvertised()
16 {
17 var folder = TestData.Get(@"TestData");
18
19 using (var fs = new DisposableFileSystem())
20 {
21 var baseFolder = fs.GetFolder();
22 var intermediateFolder = Path.Combine(baseFolder, "obj");
23 var msiPath = Path.Combine(baseFolder, @"bin", "test.msi");
24
25 var result = WixRunner.Execute(new[]
26 {
27 "build",
28 Path.Combine(folder, "Encoding", "Encoding.wxs"),
29 "-bindpath", Path.Combine(folder, "SingleFile", "data"),
30 "-intermediateFolder", intermediateFolder,
31 "-o", msiPath
32 });
33
34 var errors = result.Messages.Where(m => m.Level == MessageLevel.Error).Select(m => m.ToString().Replace(folder, "<testdata>")).ToArray();
35 WixAssert.CompareLineByLine(new[]
36 {
37 "A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.",
38 "A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.",
39 "A string was provided with characters that are not available in the specified database code page '1252'. Either change these characters to ones that exist in the database's code page, or update the database's code page by modifying one of the following attributes: Package/@Codepage, Module/@Codepage, Patch/@Codepage, or WixLocalization/@Codepage.",
40 }, errors);
41 }
42 }
43 }
44}
diff --git a/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Encoding/Encoding.wxs b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Encoding/Encoding.wxs
new file mode 100644
index 00000000..94ca33b3
--- /dev/null
+++ b/src/wix/test/WixToolsetTest.CoreIntegration/TestData/Encoding/Encoding.wxs
@@ -0,0 +1,14 @@
1<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
2 <Package Name="Ć Not In 1252 Codepage" Version="3.0.0" Codepage="1252" Manufacturer="Example Company" Language="1033" UpgradeCode="11111111-1111-1111-1111-111111111111">
3 <StandardDirectory Id="ProgramFiles6432Folder">
4 <Directory Id="INSTALLFOLDER" Name="test">
5 </Directory>
6 </StandardDirectory>
7
8 <Feature Id="Main">
9 <Component Directory="INSTALLFOLDER">
10 <File Source="test.txt" />
11 </Component>
12 </Feature>
13 </Package>
14</Wix>