Skip to content

Commit e68c2e0

Browse files
committed
[JSON] Do an experiment for deep recursion.
1 parent edcf9ac commit e68c2e0

File tree

292 files changed

+111
-51955
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

292 files changed

+111
-51955
lines changed

Package.swift

-27
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ let package = Package(
145145
"TestSupport",
146146
"FoundationEssentials"
147147
],
148-
resources: [
149-
.copy("Resources")
150-
],
151148
swiftSettings: availabilityMacros + concurrencyChecking
152149
),
153150

@@ -175,15 +172,6 @@ let package = Package(
175172
] + availabilityMacros + concurrencyChecking
176173
),
177174

178-
.testTarget(
179-
name: "FoundationInternationalizationTests",
180-
dependencies: [
181-
"TestSupport",
182-
"FoundationInternationalization",
183-
],
184-
swiftSettings: availabilityMacros + concurrencyChecking
185-
),
186-
187175
// FoundationMacros
188176
.macro(
189177
name: "FoundationMacros",
@@ -202,18 +190,3 @@ let package = Package(
202190
),
203191
]
204192
)
205-
206-
// https://github.com/apple/swift-package-manager/issues/7174
207-
// Test macro targets result in multiple definitions of `main` on Windows.
208-
#if !os(Windows)
209-
package.targets.append(contentsOf: [
210-
.testTarget(
211-
name: "FoundationMacrosTests",
212-
dependencies: [
213-
"FoundationMacros",
214-
"TestSupport"
215-
],
216-
swiftSettings: availabilityMacros + concurrencyChecking
217-
)
218-
])
219-
#endif

Sources/FoundationEssentials/JSON/JSONScanner.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ extension JSONMap.Value {
261261

262262

263263
internal struct JSONScanner {
264+
internal static let maximumRecursionDepth = JSONWriter.maximumRecursionDepth
265+
264266
let options: Options
265267
var reader: DocumentReader
266268
var depth: Int = 0
@@ -412,7 +414,7 @@ internal struct JSONScanner {
412414
mutating func scanArray() throws {
413415
let firstChar = reader.read()
414416
precondition(firstChar == ._openbracket)
415-
guard self.depth < 512 else {
417+
guard self.depth < Self.maximumRecursionDepth else {
416418
throw JSONError.tooManyNestedArraysOrDictionaries(location: reader.sourceLocation(atOffset: 1))
417419
}
418420
self.depth &+= 1
@@ -470,7 +472,7 @@ internal struct JSONScanner {
470472
mutating func scanObject() throws {
471473
let firstChar = self.reader.read()
472474
precondition(firstChar == ._openbrace)
473-
guard self.depth < 512 else {
475+
guard self.depth < Self.maximumRecursionDepth else {
474476
throw JSONError.tooManyNestedArraysOrDictionaries(location: reader.sourceLocation(atOffset: -1))
475477
}
476478
try scanObject(withoutBraces: false)

Sources/FoundationEssentials/JSON/JSONWriter.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
internal struct JSONWriter {
1414

1515
// Structures with container nesting deeper than this limit are not valid.
16-
private static let maximumRecursionDepth = 512
16+
internal static let maximumRecursionDepth = 1024
1717

1818
private var indent = 0
1919
private let pretty: Bool

Tests/FoundationEssentialsTests/AttributedString/AttributedStringCOWTests.swift

-260
This file was deleted.

0 commit comments

Comments
 (0)