Copilot commented on code in PR #4340:
URL: https://github.com/apache/arrow-adbc/pull/4340#discussion_r3277101427


##########
csharp/src/Apache.Arrow.Adbc/DriverManager/TomlParser.cs:
##########
@@ -175,70 +217,334 @@ private static object ParseValue(string raw)
                 return false;
             }
 
-            // Integer (try before float, since integers are a subset)
-            if (long.TryParse(raw, NumberStyles.Integer, 
CultureInfo.InvariantCulture, out long intValue))
+            // Integer (try before float, since integers are a subset). Reject 
TOML
+            // integer extensions (underscores, hex/oct/bin prefixes, leading 
'+') by

Review Comment:
   The comment above integer parsing says the parser rejects a leading '+' 
sign, but `IsPlainInteger`/`long.TryParse(..., NumberStyles.Integer, ...)` 
currently accept '+' (and `IsPlainInteger` explicitly allows it). Please either 
update the comment to match the implementation, or disallow '+' if that’s the 
intended restriction.
   



##########
csharp/src/Apache.Arrow.Adbc/DriverManager/TomlParser.cs:
##########
@@ -69,8 +74,13 @@ internal static Dictionary<string, Dictionary<string, 
object>> Parse(string cont
                     continue;
                 }
 
-                if (line.StartsWith("[", StringComparison.Ordinal) && 
line.EndsWith("]", StringComparison.Ordinal))
+                if (line[0] == '[')
                 {
+                    if (line[line.Length - 1] != ']')
+                    {
+                        throw new FormatException(
+                            "Invalid TOML section header '" + line + "': 
missing closing ']'.");
+                    }
                     string sectionName = line.Substring(1, line.Length - 
2).Trim();

Review Comment:
   Section-header parsing throws "missing closing ']'" whenever the last 
character isn’t ']', which is also triggered by inputs like "[foo] trailing" 
(where a closing bracket exists but there’s trailing content). Consider 
explicitly checking for a closing ']' at the end vs. detecting trailing content 
after ']' so the error message is accurate and more actionable.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to