data: json sniff rejects '[section]' / '[[table]]' (INI / TOML no longer sniffed as JSON)
This commit is contained in:
1 parent
e11f07dade
commit
b6afe0122c
1 file changed
+6
-1
@@ -36,7 +36,12 @@ function JsonFormat.sniff(r: Bytes.Reader): number
|
||||
local nxt = string.match(head, "^[^{]*{[ \t\r\n]*(.)")
|
||||
return if nxt == nil or nxt == '"' or nxt == "}" then 0.6 else 0.1
|
||||
elseif first == "[" then
|
||||
return 0.3
|
||||
-- past any nested '[': a JSON value must start (TOML / INI "[section]" and "[[table]]" do not)
|
||||
local nxt = string.match(head, "^[ \t\r\n]*[%[ \t\r\n]*(.)")
|
||||
if nxt == nil or string.find('{"-0123456789tfn]', nxt, 1, true) then
|
||||
return 0.3
|
||||
end
|
||||
return 0
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user