JSON Parsing - deadlock/stuck on parsing Json to HTML
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza en el método Parse mostrado en el issue y reproduce el bloqueo con la cadena JSON proporcionada, HtmlFormatter y el lenguaje json de ColorCode.Languages.FindById. Sigue la expresión regular compilada del lenguaje a través de regexMatch.NextMatch() y verifica que el análisis se complete sin quedarse bloqueado y que siga produciendo la salida HTML esperada.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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>());
}
}
- Lenguaje dominante
- C#
- Estrellas
- 267
- Forks
- 58
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de CommunityToolkit/ColorCode-Universal
-
Json.cs: Catastrophic regex backtracking in Regex_String causes extreme slowdown with JSON arrays Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 20/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
Todos los issues de CommunityToolkit/ColorCode-Universal
Issues similares
-
type/automation type/tech-debt
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
t/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
ci-failure-cause test-failure
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
area:auth FE mvp P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
klasolsson81/jobbliggaren#1788 ·