Skip to content

Commit

Permalink
Merged PR 690: V3.2.21 Release 17
Browse files Browse the repository at this point in the history
- Update NuGet Packages to fix vulnerabilities
  - Microsoft Security Advisory CVE-2024-43485 [System.Text.Json]
  - Microsoft Security Advisory CVE-2024-43483 [System.IO.Packaging]
- Ensure strings for doubles are converted using InvariantCulture
- 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules

Related work items: #1160
  • Loading branch information
MikeWilliams-UK committed Oct 9, 2024
1 parent 0cc0907 commit 8625de4
Show file tree
Hide file tree
Showing 57 changed files with 345 additions and 242 deletions.
54 changes: 28 additions & 26 deletions src/Chem4Word.V3/Chem4Word.V3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,20 +160,20 @@
-->
<ItemGroup>
<Reference Include="Accessibility" />
<Reference Include="Azure.Core, Version=1.41.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.41.0\lib\net461\Azure.Core.dll</HintPath>
<Reference Include="Azure.Core, Version=1.44.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.1.44.0\lib\net461\Azure.Core.dll</HintPath>
</Reference>
<Reference Include="Azure.Core.Amqp, Version=1.3.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.Amqp.1.3.0\lib\netstandard2.0\Azure.Core.Amqp.dll</HintPath>
<Reference Include="Azure.Core.Amqp, Version=1.3.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Core.Amqp.1.3.1\lib\netstandard2.0\Azure.Core.Amqp.dll</HintPath>
</Reference>
<Reference Include="Azure.Messaging.ServiceBus, Version=7.17.5.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Messaging.ServiceBus.7.17.5\lib\netstandard2.0\Azure.Messaging.ServiceBus.dll</HintPath>
<Reference Include="Azure.Messaging.ServiceBus, Version=7.18.2.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\Azure.Messaging.ServiceBus.7.18.2\lib\netstandard2.0\Azure.Messaging.ServiceBus.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml, Version=3.0.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.3.0.2\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
<Reference Include="DocumentFormat.OpenXml, Version=3.1.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.3.1.0\lib\net46\DocumentFormat.OpenXml.dll</HintPath>
</Reference>
<Reference Include="DocumentFormat.OpenXml.Framework, Version=3.0.2.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.Framework.3.0.2\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath>
<Reference Include="DocumentFormat.OpenXml.Framework, Version=3.1.0.0, Culture=neutral, PublicKeyToken=8fb06cb64d019a17, processorArchitecture=MSIL">
<HintPath>..\packages\DocumentFormat.OpenXml.Framework.3.1.0\lib\net46\DocumentFormat.OpenXml.Framework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.5.1\lib\net45\EntityFramework.dll</HintPath>
Expand Down Expand Up @@ -223,19 +223,19 @@
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.ClientModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\System.ClientModel.1.0.0\lib\netstandard2.0\System.ClientModel.dll</HintPath>
<Reference Include="System.ClientModel, Version=1.2.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8, processorArchitecture=MSIL">
<HintPath>..\packages\System.ClientModel.1.2.0\lib\netstandard2.0\System.ClientModel.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Data" />
<Reference Include="System.Data.SQLite, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\lib\net46\System.Data.SQLite.dll</HintPath>
<Reference Include="System.Data.SQLite, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\lib\net46\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.118.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.EF6.1.0.119.0\lib\net46\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.118.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.118.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.119.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\packages\System.Data.SQLite.Linq.1.0.119.0\lib\net46\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Design" />
<Reference Include="System.Diagnostics.DiagnosticSource, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
Expand All @@ -247,14 +247,14 @@
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.IO.Packaging, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Packaging.8.0.0\lib\net462\System.IO.Packaging.dll</HintPath>
<Reference Include="System.IO.Packaging, Version=8.0.0.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Packaging.8.0.1\lib\net462\System.IO.Packaging.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Memory.Data, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.Data.8.0.0\lib\net462\System.Memory.Data.dll</HintPath>
<Reference Include="System.Memory.Data, Version=8.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.Data.8.0.1\lib\net462\System.Memory.Data.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
Expand Down Expand Up @@ -301,8 +301,8 @@
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.4\lib\net462\System.Text.Json.dll</HintPath>
<Reference Include="System.Text.Json, Version=8.0.0.5, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.8.0.5\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
Expand Down Expand Up @@ -353,6 +353,7 @@
<Compile Include="Helpers\ConfigWatcher.cs" />
<Compile Include="Helpers\ReferenceKeeper.cs" />
<Compile Include="Helpers\RegistryHelper.cs" />
<Compile Include="Helpers\RegistryMessage.cs" />
<Compile Include="Helpers\TargetWord.cs" />
<Compile Include="Helpers\TaskPaneHelper.cs" />
<Compile Include="Helpers\UpdateHelper.cs" />
Expand Down Expand Up @@ -493,6 +494,7 @@
<None Include="Data\Chem4Word-Versions.xsd">
<SubType>Designer</SubType>
</None>
<None Include="Data\Insert Test Messages.reg" />
<None Include="Data\This-Version.xsd">
<SubType>Designer</SubType>
</None>
Expand Down Expand Up @@ -704,10 +706,10 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
<Error Condition="!Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.5.1\build\EntityFramework.props'))" />
<Error Condition="!Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.5.1\build\EntityFramework.targets'))" />
<Error Condition="!Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets'))" />
</Target>
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.118.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
<Import Project="..\packages\EntityFramework.6.5.1\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.5.1\build\EntityFramework.targets')" />
<Import Project="..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets" Condition="Exists('..\packages\Stub.System.Data.SQLite.Core.NetFramework.1.0.119.0\build\net46\Stub.System.Data.SQLite.Core.NetFramework.targets')" />
</Project>
8 changes: 4 additions & 4 deletions src/Chem4Word.V3/Data/Chem4Word-Versions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<Version>
<Number>3.2.21 Release 17</Number>
<IsBeta>false</IsBeta>
<Released>30-Sep-2024</Released>
<Released>09-Oct-2024</Released>
<Changes>
<Change>BugFix: ...</Change>
<Change>BugFix: ...</Change>
<Change>Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-43485 [System.Text.Json])</Change>
<Change>Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-43483 [System.IO.Packaging])</Change>
<Change>BugFix: Ensure strings for doubles are converted using InvariantCulture</Change>
<Change>BugFix: 'System.NullReferenceException: Object reference not set to an instance of an object' sometimes seen after editing a structure to combine two molecules</Change>
<Change>Please note any previous beta versions V3.2.4 and below will cease to allow insertion or editing of chemistry</Change>
Expand All @@ -34,7 +34,7 @@
<Change>BugFix: Prevent html input in searchers</Change>
<Change>UX: Prohibit import of binary files</Change>
<Change>BugFix: User unable to hide Hydrogens in Renderer (seen in Word document)</Change>
<Change>Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-30105)</Change>
<Change>Security: Update NuGet packages (Microsoft Security Advisory CVE-2024-30105 [System.Text.Json])</Change>
</Changes>
</Version>
<Version>
Expand Down
Binary file added src/Chem4Word.V3/Data/Insert Test Messages.reg
Binary file not shown.
2 changes: 1 addition & 1 deletion src/Chem4Word.V3/Data/This-Version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<Version>
<Number>3.2.21 Release 17</Number>
<IsBeta>false</IsBeta>
<Released>30-Sep-2024</Released>
<Released>09-Oct-2024</Released>
</Version>
24 changes: 18 additions & 6 deletions src/Chem4Word.V3/Data/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Chemistry for Word Add-In Version 2022</title>
<title>Chemistry for Word Add-In</title>

<!-- Analytics -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-THMT853Q01" data-cfasync="false" type="text/javascript"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-THMT853Q01');
</script>
Expand All @@ -18,7 +18,7 @@
<link rel="stylesheet" type="text/css" href="/css/slider.css" />
</head>
<body bgcolor="white">
<h1><a href="https://www.chem4word.co.uk">Chemistry for Word Add-In 2022</a></h1>
<h1><a href="https://www.chem4word.co.uk">Chemistry for Word Add-In</a></h1>

<!-- Slideshow container -->
<div class="slideshow-container fade">
Expand Down Expand Up @@ -66,17 +66,29 @@ <h1><a href="https://www.chem4word.co.uk">Chemistry for Word Add-In 2022</a></h1

<hr>

<h1>Chem4Word Versions</h1>
<table border="1" cellpadding="10">
<tr>
<td>Version History</td>
<td><a href="/files3-2/Chem4Word-Versions.xml">Chem4Word-Versions.xml</a></td>
<th>&nbsp;</th>
<th>Version 3.3 (latest)</th>
<th>Version 3.2 (this version)</th>
<th>Version 3.1</th>
</tr>
<tr>
<td>Setup Bootstrapper</td>
<td><a href="/files3-3/Chem4Word-Setup.exe">Chem4Word-Setup</a></td>
<td><a href="/files3-2/Chem4Word-Setup.exe">Chem4Word-Setup</a></td>
<td>Chem4Word-Setup</td>
</tr>
<tr>
<td>Version History</td>
<td><a href="/files3-3/Chem4Word-Versions.xml">Chem4Word-Versions.xml</a></td>
<td><a href="/files3-2/Chem4Word-Versions.xml">Chem4Word-Versions.xml</a></td>
<td><a href="/files3-1/Chem4Word-Versions.xml">Chem4Word-Versions.xml</a></td>
</tr>
</table>
<h1>Third Party</h1>

<h2>Third Party dependencies</h2>
<table border="1" cellpadding="10">
<tr>
<td>.Net Framework 4.6.2</td>
Expand Down
82 changes: 52 additions & 30 deletions src/Chem4Word.V3/Helpers/RegistryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,63 +120,85 @@ public static void SendExceptions()

private static void SendValues(string module, string level, RegistryKey registryKey)
{
var names = registryKey.GetValueNames();
var values = new List<string>();
var keys = registryKey.GetValueNames();
var values = new List<RegistryMessage>();

foreach (var name in names)
foreach (var key in keys)
{
var message = registryKey.GetValue(name).ToString();
var value = registryKey.GetValue(key).ToString();

var timestamp = name;
var timestamp = key;
var bracket = timestamp.IndexOf("[", StringComparison.InvariantCulture);
if (bracket > 0)
{
timestamp = timestamp.Substring(0, bracket).Trim();
}

values.Add($"{timestamp} {message}");
registryKey.DeleteValue(name);
var temp = new RegistryMessage
{
Date = timestamp
};

bracket = value.IndexOf("]", StringComparison.InvariantCulture);
if (bracket > 0)
{
temp.ProcessId = value.Substring(1, bracket - 1).Trim();
temp.Message = value.Substring(bracket + 1).Trim();
}
else
{
temp.Message = value;
}

values.Add(temp);
registryKey.DeleteValue(key);
}

// Group the messages by day
var groupedByDay = values
.GroupBy(g => g.Substring(0, 10))
var days = values
.GroupBy(g => g.Date.Substring(0, 10))
.ToList();

var depth = 0;
foreach (var group in groupedByDay)
foreach (var day in days)
{
SendData(module, level, group.ToList(), ref depth);
SendData(module, level, day.ToList(), ref depth);
}
}

private static void SendData(string module, string level, List<string> values, ref int depth)
private static void SendData(string module, string level, List<RegistryMessage> messages, ref int depth)
{
if (values.Any())
if (messages.Any())
{
depth++;

var message = string.Join(Environment.NewLine, values);
// Group messages by process id
var processes = messages
.GroupBy(g => g.ProcessId)
.ToList();

if (values.Count == 1 || message.Length < 32_000)
{
// Single value or message small enough to send
Globals.Chem4WordV3.Telemetry.Write(module, level, message);
}
else
foreach (var process in processes)
{
// Ensure that the recursion doesn't get too deep
if (depth < 4)
var message = string.Join(Environment.NewLine, process.ToList());
// Maximum length of a message in Azure Service bus is 32K, use 125 for testing
if (message.Length < 32_000)
{
// Split it into smaller groups, by hour, minute, second
var extra = depth * 3;
var groups = values
.GroupBy(g => g.Substring(0, 10 + extra))
.ToList();

foreach (var group in groups)
Globals.Chem4WordV3.Telemetry.Write(module, level, message);
}
else
{
if (depth < 4)
{
SendData(module, level, group.ToList(), ref depth);
var extra = depth * 3;

// Re-Group by Hour, Minute, Second based on depth
var groups = messages
.GroupBy(g => g.Date.Substring(0, 10 + extra))
.ToList();
foreach (var group in groups)
{
SendData(module, level, group.ToList(), ref depth);
}
}
}
}
Expand Down
Loading

0 comments on commit 8625de4

Please sign in to comment.