From 0f1e96bbbf7aabb16e7599150fb80372561b8e3c Mon Sep 17 00:00:00 2001 From: jallers Date: Mon, 11 Aug 2025 18:42:25 -0400 Subject: [PATCH 1/2] Retarget 4.8 --- ...rsionOne.Localization.csproj.dtbcache.json | 1 + source/VersionOne.Localization.csproj | 7 ++- tests/VersionOne.Localization.Tests.csproj | 7 ++- web/Web.config | 45 ++++++++++--------- web/web.csproj | 16 ++++--- 5 files changed, 45 insertions(+), 31 deletions(-) create mode 100644 source/.vs/VersionOne.Localization.csproj.dtbcache.json diff --git a/source/.vs/VersionOne.Localization.csproj.dtbcache.json b/source/.vs/VersionOne.Localization.csproj.dtbcache.json new file mode 100644 index 0000000..7147620 --- /dev/null +++ b/source/.vs/VersionOne.Localization.csproj.dtbcache.json @@ -0,0 +1 @@ +{"RootPath":"D:\\source\\VersionOne.Localization\\source","ProjectFileName":"VersionOne.Localization.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"AssemblyInfo.cs"},{"SourceFile":"FileTemplateSetLoader.cs"},{"SourceFile":"LocalizationManager.cs"},{"SourceFile":"Localizer.cs"},{"SourceFile":"TemplateProvider.cs"},{"SourceFile":"TemplateSet.cs"},{"SourceFile":"TextTemplateSet.cs"},{"SourceFile":"Translator.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.0.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\WINDOWS\\Microsoft.NET\\Framework\\v4.0.30319\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System.Core\\v4.0_4.0.0.0__b77a5c561934e089\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\WINDOWS\\Microsoft.Net\\assembly\\GAC_MSIL\\System\\v4.0_4.0.0.0__b77a5c561934e089\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"D:\\source\\VersionOne.Localization\\source\\bin\\Debug\\VersionOne.Localization.dll","OutputItemRelativePath":"VersionOne.Localization.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/source/VersionOne.Localization.csproj b/source/VersionOne.Localization.csproj index 4802507..0865222 100644 --- a/source/VersionOne.Localization.csproj +++ b/source/VersionOne.Localization.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,8 +10,9 @@ Properties VersionOne.Localization VersionOne.Localization - v4.0 + v4.8 512 + true @@ -22,6 +23,7 @@ prompt 4 false + false pdbonly @@ -31,6 +33,7 @@ prompt 4 false + false diff --git a/tests/VersionOne.Localization.Tests.csproj b/tests/VersionOne.Localization.Tests.csproj index 5ffe085..d8fa999 100644 --- a/tests/VersionOne.Localization.Tests.csproj +++ b/tests/VersionOne.Localization.Tests.csproj @@ -1,5 +1,5 @@  - + Debug AnyCPU @@ -10,8 +10,9 @@ Properties VersionOne.Localization.Tests VersionOne.Localization.Tests - v4.0 + v4.8 512 + true @@ -22,6 +23,7 @@ prompt 4 false + false pdbonly @@ -31,6 +33,7 @@ prompt 4 false + false diff --git a/web/Web.config b/web/Web.config index 3626d03..8d85a5a 100644 --- a/web/Web.config +++ b/web/Web.config @@ -1,46 +1,47 @@ - - + - + - - - + + + - - + - - + - - - - + + + + - - - + + - - - + + - - + \ No newline at end of file diff --git a/web/web.csproj b/web/web.csproj index 094a3c5..4ec636c 100644 --- a/web/web.csproj +++ b/web/web.csproj @@ -1,5 +1,5 @@  - + Debug @@ -13,7 +13,7 @@ Properties web web - v4.0 + v4.8 false false true @@ -21,6 +21,7 @@ 4.0 + true @@ -31,6 +32,7 @@ prompt 4 false + false pdbonly @@ -40,16 +42,20 @@ prompt 4 false + false - - 3.5 - + + + + + + From 8ba3462412225c437378dc5326b403de42c87adc Mon Sep 17 00:00:00 2001 From: jallers Date: Mon, 11 Aug 2025 18:45:21 -0400 Subject: [PATCH 2/2] Add a timeout to Regular expression --- source/Localizer.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Localizer.cs b/source/Localizer.cs index 134bb52..6fc7848 100644 --- a/source/Localizer.cs +++ b/source/Localizer.cs @@ -28,13 +28,14 @@ public class Localizer : ILocalizerResolver private const char SeparatorChar = '\''; private const char LeftBraceChar = '{'; private const char RightBraceChar = '}'; + private static readonly TimeSpan RegexTimeout = TimeSpan.FromSeconds(1); private const string LeftBracePlaceholderString = "\x2"; private const char LeftBracePlaceholderChar = '\x2'; private const string RightBracePlaceholderString = "\x3"; private const char RightBracePlaceholderChar = '\x3'; - private static readonly Regex rxEmbeddedTag = new Regex(@"\{([^{}]*)\}", RegexOptions.Compiled); - private static readonly Regex rxDoubleLeftBrace = new Regex(@"\{\{", RegexOptions.Compiled); - private static readonly Regex rxDoubleRightBrace = new Regex(@"\}\}", RegexOptions.RightToLeft | RegexOptions.Compiled); + private static readonly Regex rxEmbeddedTag = new Regex(@"\{([^{}]*)\}", RegexOptions.Compiled, RegexTimeout); + private static readonly Regex rxDoubleLeftBrace = new Regex(@"\{\{", RegexOptions.Compiled, RegexTimeout); + private static readonly Regex rxDoubleRightBrace = new Regex(@"\}\}", RegexOptions.RightToLeft | RegexOptions.Compiled, RegexTimeout); private static string StripLiteralBraces (string input) {