From 0c2323fcbed070f088fcf5da15e06e04d325c61d Mon Sep 17 00:00:00 2001 From: Linquize Date: Tue, 17 Mar 2020 13:19:16 +0800 Subject: [PATCH 1/2] Fix crashes that handle both 'key: value' and 'key:value' --- UserInterface/Port.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/UserInterface/Port.cs b/UserInterface/Port.cs index b8024ec..aded6a3 100644 --- a/UserInterface/Port.cs +++ b/UserInterface/Port.cs @@ -40,9 +40,14 @@ public static List> ParseParagraph(string filepath) } else { - var lsplit = line.Split(new string[] { ": " }, 2, StringSplitOptions.RemoveEmptyEntries); - paragraph.Add(lsplit[0], lsplit.Length < 2 ? string.Empty : lsplit[1]); - lastkey = lsplit[0]; + int colon = line.IndexOf(':'); + if (colon > 0) + { + var key = line.Substring(0, colon); + var value = line.Substring(colon + 1); + paragraph.Add(key, value); + lastkey = key; + } } } if(paragraph.Count >0) result.Add(paragraph); @@ -131,7 +136,7 @@ public static List ParseStatus(string statusFile) case "Depends": status.Depends = CommaSplit(item.Value); break; case "Description": status.Description = item.Value; break; case "Status": - var strs = item.Value.Split(' '); + var strs = item.Value.Trim().Split(' '); status.Want = (Want)Enum.Parse(typeof(Want), strs[0], true); status.State = InstallStateParser[strs[2]]; break; From 8ef4d0b6b8adf6af9d5a16af8d4bc83a864518a8 Mon Sep 17 00:00:00 2001 From: Linquize Date: Tue, 17 Mar 2020 13:19:39 +0800 Subject: [PATCH 2/2] Fix NotSupportedException at "Supports" key --- UserInterface/Port.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UserInterface/Port.cs b/UserInterface/Port.cs index aded6a3..6c683e0 100644 --- a/UserInterface/Port.cs +++ b/UserInterface/Port.cs @@ -74,7 +74,7 @@ public static Port ParseControlFile(string filepath) case "Description": port.CoreParagraph.Description = item.Value; break; case "Maintainer": port.CoreParagraph.Maintainer = item.Value; break; case "Default-Features": port.CoreParagraph.DefaultFeatures = CommaSplit(item.Value); break; - case "Supports": throw new NotSupportedException(); + case "Supports": port.CoreParagraph.Supports = CommaSplit(item.Value); break; } } else if (paragraph.Keys.Contains(FeatureToken))