Skip to content

regexp/syntax: document limit of 1000 in {n,m} quantifier forms #7252

@athomason

Description

@athomason
What steps will reproduce the problem?
1. Using a value of n or m greater than 1000 in any of the x{n,m}, x{n,}, x{n}
quantifier forms produces an ErrInvalidRepeatSize. http://play.golang.org/p/tD9yMerkbn.
ErrInvalidRepeatSize is not documented to have such a limit.


What is the expected output?
A working Regexp, or at least a more helpful error message.


What do you see instead?
"invalid repeat count". There is no mention in the documentation that there is
a limit of 1000; I had to look at regexp/syntax/parse.go to uncover it:
https://code.google.com/p/go/source/browse/src/pkg/regexp/syntax/parse.go#758


Which compiler are you using (5g, 6g, 8g, gccgo)?
6g


Which operating system are you using?
Ubuntu 12.04


Which version are you using?  (run 'go version')
go version go1.2 linux/amd64


Please provide any additional information below.
This code was pulled in from re2 in rev c0852f6d0549. It looks like the limit has been
in re2 itself since the first public commit:
https://code.google.com/p/re2/source/browse/re2/parse.cc?spec=svn166b9c1905c7b1bd26a20cbf2f5c1f66823af1c0&;r=166b9c1905c7b1bd26a20cbf2f5c1f66823af1c0#435.
I can find no mention of why this limit is necessary or why 1000 is an appropriate value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions