Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Release Notes

## 8.1.3 - Mar 23 2026

- Fix JSON `/* ... */` comment parser: `*` or `/` characters inside the comment body no longer cause premature termination and parse failure

## 8.1.2 - Mar 17 2026

- Fix `TextConversions.AsDateTime` and `TextConversions.AsDateTimeOffset` to return `None` (instead of throwing `ArgumentOutOfRangeException`) when a `/Date(...)/` value overflows the valid `DateTime`/`DateTimeOffset` range; use `InvariantCulture` explicitly when parsing the milliseconds value
Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Data.Json.Core/JsonValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ type private JsonParser(jsonText: string) =
else if i < s.Length && s.[i] = '*' then
i <- i + 1

while i + 1 < s.Length && s.[i] <> '*' && s.[i + 1] <> '/' do
while i + 1 < s.Length && (s.[i] <> '*' || s.[i + 1] <> '/') do
i <- i + 1

ensure (i + 1 < s.Length && s.[i] = '*' && s.[i + 1] = '/')
Expand Down
20 changes: 20 additions & 0 deletions tests/FSharp.Data.Core.Tests/JsonValue.fs
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,26 @@ let ``JsonValue parsing with multi-line comments`` () =
let result = JsonValue.Parse jsonWithComments
result?data.AsString() |> should equal "valid"

[<Test>]
let ``JsonValue parsing with multi-line comment containing asterisk`` () =
// Bug: old code used '&&' so a '*' anywhere inside stopped scanning too early
let json = """{ /* a * b */ "x": 1 }"""
let result = JsonValue.Parse json
result?x.AsInteger() |> should equal 1

[<Test>]
let ``JsonValue parsing with multi-line comment containing slash`` () =
// Bug: old code used '&&' so a '/' anywhere inside stopped scanning too early
let json = """{ /* path/to/file */ "x": 2 }"""
let result = JsonValue.Parse json
result?x.AsInteger() |> should equal 2

[<Test>]
let ``JsonValue parsing with multi-line comment containing both asterisk and slash`` () =
let json = "{ /* a/b * c */ \"x\": 3 }"
let result = JsonValue.Parse json
result?x.AsInteger() |> should equal 3

[<Test>]
let ``JsonValue parsing with mixed whitespace and comments`` () =
let jsonWithCommentsAndWhitespace = """
Expand Down
Loading