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
@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
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
Contributor

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
Contributor

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

@ianlancetaylor
Copy link
Member

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 <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
@gopherbot
Copy link
Contributor

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 <[email protected]>
Reviewed-by: Ian Lance Taylor <[email protected]>
Run-TryBot: Ian Lance Taylor <[email protected]>
Auto-Submit: Ian Lance Taylor <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: Rob Pike <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
@rsc rsc moved this to Accepted in Proposals Aug 10, 2022
@rsc rsc added this to Proposals Aug 10, 2022
@rsc rsc removed this from Proposals Apr 6, 2023
@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
None yet
Development

No branches or pull requests

6 participants