From f4bdb422232fda3aa520ac704630d7d0f21322d2 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Thu, 17 Oct 2024 09:49:15 +0700 Subject: [PATCH] Fix bug with too-long substrings (#350) C#'s string.Substring method throws an exception if length is beyond the end of the string, so we need to check the string length first. --- src/LfMerge.Core/Reporting/ConversionError.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/LfMerge.Core/Reporting/ConversionError.cs b/src/LfMerge.Core/Reporting/ConversionError.cs index da6607a3..4c64b4cb 100644 --- a/src/LfMerge.Core/Reporting/ConversionError.cs +++ b/src/LfMerge.Core/Reporting/ConversionError.cs @@ -118,7 +118,8 @@ public string MongoId() { } public string Label() { - if (Comment == null || Comment.Content == null) return string.Empty; + if (Comment == null || String.IsNullOrEmpty(Comment.Content)) return string.Empty; + if (Comment.Content.Length < 100) return Comment.Content; return Comment.Content.Substring(0, 100); } }