JSON Parsing - deadlock/stuck on parsing Json to HTML
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu từ phương thức Parse được hiển thị trong issue và tái hiện tình trạng treo bằng chuỗi JSON được cung cấp, HtmlFormatter và ngôn ngữ json từ ColorCode.Languages.FindById. Theo dõi regex của ngôn ngữ đã được biên dịch qua regexMatch.NextMatch() và xác minh rằng quá trình phân tích hoàn tất mà không bị đình trệ, đồng thời vẫn tạo ra đầu ra HTML như mong đợi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Im trying to parse this JSON sipped to my Blazor page. But because of some weird RegEx parsing issue the process get stuck without any Exception. Can somebody tell me where there could be a Problem?
here you can find my test project: ColorCodeTest
This is my Test Code
string _jsonString3 = "{\r\n \"raw_causes\": [\r\n \"Winterglatter Fahrbahn\",\r\n \"Nicht angepasste Geschwindigkeit\",\r\n \"test3\"\r\n ]\r\n }";
try
{
var _formatter = new HtmlFormatter();
var language = ColorCode.Languages.FindById("json");
_jsonHtml = _formatter.GetHtmlString(_jsonString3, language);
}
catch (Exception)
{
throw;
}
It stuck after the array Element \"Winterglatter Fahrbahn\", when it call regexMatch = regexMatch.NextMatch(); and I have no idear why this happends
private void Parse(string sourceCode,
CompiledLanguage compiledLanguage,
Action<string, IList<Scope>> parseHandler)
{
Match regexMatch = compiledLanguage.Regex.Match(sourceCode);
if (!regexMatch.Success)
parseHandler(sourceCode, new List<Scope>());
else
{
int currentIndex = 0;
try
{
while (regexMatch.Success)
{
string sourceCodeBeforeMatch = sourceCode.Substring(currentIndex, regexMatch.Index - currentIndex);
if (!string.IsNullOrEmpty(sourceCodeBeforeMatch))
parseHandler(sourceCodeBeforeMatch, new List<Scope>());
string matchedSourceCode = sourceCode.Substring(regexMatch.Index, regexMatch.Length);
if (!string.IsNullOrEmpty(matchedSourceCode))
{
List<Scope> capturedStylesForMatchedFragment = GetCapturedStyles(regexMatch, regexMatch.Index, compiledLanguage);
List<Scope> capturedStyleTree = CreateCapturedStyleTree(capturedStylesForMatchedFragment);
parseHandler(matchedSourceCode, capturedStyleTree);
}
currentIndex = regexMatch.Index + regexMatch.Length;
regexMatch = regexMatch.NextMatch();
}
}
catch (Exception ex)
{
throw;
}
string sourceCodeAfterAllMatches = sourceCode.Substring(currentIndex);
if (!string.IsNullOrEmpty(sourceCodeAfterAllMatches))
parseHandler(sourceCodeAfterAllMatches, new List<Scope>());
}
}
- Ngôn ngữ chính
- C#
- Star
- 267
- Fork
- 58
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của CommunityToolkit/ColorCode-Universal
-
Json.cs: Catastrophic regex backtracking in Regex_String causes extreme slowdown with JSON arrays Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
Tất cả issue của CommunityToolkit/ColorCode-Universal
Issue tương tự
-
[Feat] 조합 영역 구분선 개선 Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
type/automation type/tech-debt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
t/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
ci-failure-cause test-failure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100