From 39597745a50f8b6950fef3138e9859d54b2d1e74 Mon Sep 17 00:00:00 2001 From: Alex Crome Date: Thu, 26 Sep 2024 09:45:33 +0100 Subject: [PATCH] Fix bugs --- .../Builders/Rendering/HtmlRenderer.cs | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs b/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs index a29996ff..d541903b 100644 --- a/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs +++ b/src/ReportGenerator.Core/Reporting/Builders/Rendering/HtmlRenderer.cs @@ -1125,7 +1125,7 @@ void WriteSeries(TextWriter series) this.reportTextWriter.WriteLine("var historyChartData{0} = {{", id); this.reportTextWriter.Write(" \"series\" : ["); WriteSeries(this.reportTextWriter); - this.reportTextWriter.WriteLine("],\""); + this.reportTextWriter.WriteLine("],"); this.reportTextWriter.WriteLine( " \"tooltips\" : [{0}]", @@ -1580,27 +1580,33 @@ private void SaveCss(string targetDirectory) return; } - using (var fs = new FileStream(targetPath, FileMode.Create)) + if (this.htmlMode == HtmlMode.InlineCssAndJavaScript) { - if (this.htmlMode != HtmlMode.InlineCssAndJavaScript) + using (var fs = new FileStream(targetPath, FileMode.Create)) + using (var writer = new StreamWriter(fs)) { - var builder = StringBuilderCache.Get(); - using (var writer = new StringWriter(builder)) - { - this.WriteCss(writer); - } + this.WriteCss(writer); + } + } + else + { + var builder = StringBuilderCache.Get(); + using (var writer = new StringWriter(builder)) + { + this.WriteCss(writer); + } - string css = StringBuilderCache.ToStringAndReturnToPool(builder); - var matches = Regex.Matches(css, @"url\(icon_(?.+).svg\),\surl\(data:image/svg\+xml;base64,(?.+)\)"); + string css = StringBuilderCache.ToStringAndReturnToPool(builder); - foreach (Match match in matches) - { - System.IO.File.WriteAllBytes( - Path.Combine(targetDirectory, "icon_" + match.Groups["filename"].Value + ".svg"), - Convert.FromBase64String(match.Groups["base64image"].Value)); - } + System.IO.File.WriteAllText(targetPath, css); + + var matches = Regex.Matches(css, @"url\(icon_(?.+).svg\),\surl\(data:image/svg\+xml;base64,(?.+)\)"); - StringBuilderCache.Return(builder); + foreach (Match match in matches) + { + System.IO.File.WriteAllBytes( + Path.Combine(targetDirectory, "icon_" + match.Groups["filename"].Value + ".svg"), + Convert.FromBase64String(match.Groups["base64image"].Value)); } }