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

regexp: add ErrNestingDepth error #51684

Closed
rsc opened this issue Mar 15, 2022 · 9 comments
Closed

regexp: add ErrNestingDepth error #51684

rsc opened this issue Mar 15, 2022 · 9 comments

Comments

@rsc
Copy link
Contributor

rsc commented Mar 15, 2022

The fix for #51112 introduced a nesting depth check in the regexp parser.
To avoid adding new API, the fix returns ErrInternalError on regexps that are too deeply nested.
For Go 1.19 we want to give this error a proper value with a good message.

I propose to add a new ErrorCode:

ErrNestingDepth          ErrorCode = "expression nests too deeply"

The code change is in CL 384617.

@rsc rsc added this to the Proposal milestone Mar 15, 2022
@ianlancetaylor ianlancetaylor added this to Incoming in Proposals (old) Mar 15, 2022
@rsc rsc moved this from Incoming to Active in Proposals (old) Mar 16, 2022
@rsc
Copy link
Contributor Author

rsc commented Mar 16, 2022

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc
Copy link
Contributor Author

rsc commented Mar 23, 2022

Based on the discussion above, this proposal seems like a likely accept.
— rsc for the proposal review group

@rsc rsc moved this from Active to Likely Accept in Proposals (old) Mar 23, 2022
@rsc rsc moved this from Likely Accept to Accepted in Proposals (old) Mar 30, 2022
@rsc
Copy link
Contributor Author

rsc commented Mar 30, 2022

No change in consensus, so accepted. 🎉
This issue now tracks the work of implementing the proposal.
— rsc for the proposal review group

@rsc rsc changed the title proposal: regexp: add ErrNestingDepth error regexp: add ErrNestingDepth error Mar 30, 2022
@rsc rsc modified the milestones: Proposal, Backlog Mar 30, 2022
@gopherbot
Copy link

Change https://go.dev/cl/384617 mentions this issue: regexp/syntax: add and use ErrInvalidDepth

@mibk
Copy link
Contributor

mibk commented Apr 6, 2022

The proposed changed was

ErrNestingDepth          ErrorCode = "expression nests too deeply"

while the actual change uses

ErrInvalidDepth          ErrorCode = "invalid nesting depth"

Was that intentional? Also, there was a suggestion by Rob Pike to use

ErrTooDeep               ErrorCode = "expression nests too deeply"

@dmitshur dmitshur modified the milestones: Backlog, Go1.19 Apr 8, 2022
@robpike
Copy link
Contributor

robpike commented Apr 19, 2022

I agree, this was not resolved to my satisfaction. Did something get missed?

@gopherbot
Copy link

Change https://go.dev/cl/401076 mentions this issue: regexp: change ErrInvalidDepth message to match proposal

@ianlancetaylor
Copy link
Contributor

Sent https://go.dev/cl/401076.

gopherbot pushed a commit that referenced this issue Apr 22, 2022
Also update the file in $GOROOT/api/next to use proposal number.

For #51684

Change-Id: I28bfa6bc1cee98a17b13da196d41cda34d968bb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/401076
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
@gopherbot
Copy link

Change https://go.dev/cl/401854 mentions this issue: regexp/syntax: rename ErrInvalidDepth to ErrNestingDepth

gopherbot pushed a commit that referenced this issue Apr 22, 2022
The proposal accepted the name ErrNestingDepth.

For #51684

Change-Id: I702365f19e5e1889dbcc3c971eecff68e0b08727
Reviewed-on: https://go-review.googlesource.com/c/go/+/401854
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
@golang golang locked and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

6 participants