Skip to content

StringIndexOutOfBoundsException in parseEscape #103

@dwoffinden

Description

@dwoffinden
jshell> com.google.re2j.Pattern.compile("\\x")
|  Exception com.google.re2j.PatternSyntaxException: error parsing regexp: invalid escape sequence: `\x`
|        at Parser.parseEscape (Parser.java:1440)
|        at Parser.parseInternal (Parser.java:962)
|        at Parser.parse (Parser.java:788)
|        at RE2.compileImpl (RE2.java:184)
|        at Pattern.compile (Pattern.java:136)
|        at Pattern.compile (Pattern.java:96)
|        at (#1:1)

vs

jshell> com.google.re2j.Pattern.compile("\\xv")
|  Exception java.lang.StringIndexOutOfBoundsException: index 3,length 3
|        at String.checkIndex (String.java:3278)
|        at String.codePointAt (String.java:723)
|        at Parser$StringIterator.pop (Parser.java:751)
|        at Parser.parseEscape (Parser.java:1414)
|        at Parser.parseInternal (Parser.java:962)
|        at Parser.parse (Parser.java:788)
|        at RE2.compileImpl (RE2.java:184)
|        at Pattern.compile (Pattern.java:136)
|        at Pattern.compile (Pattern.java:96)
|        at (#2:1)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions