JSON Parsing - deadlock/stuck on parsing Json to HTML
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par la méthode Parse présentée dans l’issue et reproduisez le blocage avec la chaîne JSON fournie, HtmlFormatter et le langage json de ColorCode.Languages.FindById. Suivez l’expression régulière compilée du langage à travers regexMatch.NextMatch() et vérifiez que l’analyse se termine sans rester bloquée tout en produisant toujours la sortie HTML attendue.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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>());
}
}
- Langage dominant
- C#
- Étoiles
- 267
- Forks
- 58
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de CommunityToolkit/ColorCode-Universal
-
Json.cs: Catastrophic regex backtracking in Regex_String causes extreme slowdown with JSON arrays Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 20/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 30/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 38/100
-
Difficulté 3/5 1-2 jours Accessibilité débutants 38/100
Toutes les issues de CommunityToolkit/ColorCode-Universal
Issues similaires
-
[Feat] 조합 영역 구분선 개선 Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
type/automation type/tech-debt
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
-
t/bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
ci-failure-cause test-failure
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100