Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use swift/main for development #759

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ Specifically, `_RegexParser` contains the parser for regular expression literals

### Branching scheme

#### Development branch

The `main` branch is the branch for day-to-day development. Generally, you should create PRs against this branch.

#### Swift integration branches

Branches whose name starts with `swift/` are Swift integration branches similar to those in [apple/llvm-project](https://github.com/apple/llvm-project). For each branch, dropping the `swift/` prefix is the corresponding branch in [apple/swift](https://github.com/apple/swift).

This package's `main` branch will automatically integrate with Swift's `main` branch.

| apple/swift branch | apple/swift-experimental-string-processing branch |
| ------------------- | ----------------------------------------------------- |
| main | swift/main |
| main | main |
| release/5.7 | swift/release/5.7 |
| ... | swift/... |

A pair of corresponding branches are expected to build successfully together and pass all tests.

### Integration workflow
### Running Package CI and full Swift CI

To integrate the latest changes in apple/swift-experimental-string-processing to apple/swift, carefully follow the workflow:

- Create pull requests.
- Create a branch from a commit on `main` that you would like to integrate into `swift/main`.
- Create a pull request in apple/swift-experimental-string-processing from that branch to `swift/main`, e.g. "[Integration] main (<commit>) -> swift/main".
- Run package CI
- In the pull request, trigger package CI using
```
@swift-ci please test
```
- Run full Swift CI for any changes to public or SPI interfaces or the `_RegexParser` module.
- If apple/swift needs to be modified to work with the latest `main` in apple/swift-experimental-string-processing, create a pull request in apple/swift. **Note:** Since CI in apple/swift-experimental-string-processing has not yet been set up to run full toolchain tests, you should create a PR in apple/swift regardless; if the integartion does not require changing apple/swift, create a dummy PR in apple/swift by changing the README and just not merge it in the end.
- Trigger CI.
- In the apple/swift-experimental-string-processing pull request, trigger CI using the following command (replacing `<PR NUMBER>` with the apple/swift pull request number, if any):
```
apple/swift#<PR NUMBER> # use this line only if there is an corresponding apple/swift PR
Expand All @@ -75,7 +75,9 @@ To integrate the latest changes in apple/swift-experimental-string-processing to
@swift-ci please test
```
- Merge when approved.
- Merge the pull request in apple/swift-experimental-string-processing as a **merge commit**.
- Merge the PR in apple/swift-experimental-string-processing:
- as a squash or rebase if against main (the development branch).
- as a merge commit if it's a merge from main to swift/release/x.y.
- Merge the pull request in apple/swift (if any).

### Development notes
Expand Down
13 changes: 13 additions & 0 deletions Sources/_RegexParser/Regex/Parse/Parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,19 @@ extension Parser {
mutating func parseCustomCharacterClass(
_ start: Source.Located<CustomCC.Start>
) -> CustomCC {
// Excessively nested recursion is a common DOS attack, so limit
// our recursion.
context.parseDepth += 1
defer { context.parseDepth -= 1 }
guard context.parseDepth < context.maxParseDepth else {
self.errorAtCurrentPosition(.nestingTooDeep)

// This is not generally recoverable and further errors will be
// incorrect
diags.suppressFurtherDiagnostics = true
return .init(start, [], start.location)
}

let alreadyInCCC = context.isInCustomCharacterClass
context.isInCustomCharacterClass = true
defer { context.isInCustomCharacterClass = alreadyInCCC }
Expand Down
7 changes: 7 additions & 0 deletions Tests/RegexTests/ParseTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3335,6 +3335,13 @@ extension RegexTests {
+ "a"
+ String(repeating: ")*", count: 500),
.nestingTooDeep)

diagnosticTest(
String(repeating: "[", count: 500)
+ "a"
+ String(repeating: "]*", count: 500),
.nestingTooDeep)

}

func testDelimiterLexingErrors() {
Expand Down