Skip to content

Commit

Permalink
bugfix for regex matches ending with non-ASCII (#26831)
Browse files Browse the repository at this point in the history
Ref #26831
(cherry picked from commit aed8a84)
  • Loading branch information
stevengj authored and ararslan committed Apr 27, 2018
1 parent 17b5f3a commit 9aedbcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ function next(itr::RegexMatchIterator, prev_match)
offset = prev_match.offset
end
else
offset = prev_match.offset + endof(prev_match.match)
offset = prev_match.offset + sizeof(prev_match.match)
end

opts_nonempty = UInt32(PCRE.ANCHORED | PCRE.NOTEMPTY_ATSTART)
Expand Down
8 changes: 8 additions & 0 deletions test/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ target = """71.163.72.113 - - [30/Jul/2014:16:40:55 -0700] "GET emptymind.org/th
pat = r"""([\d\.]+) ([\w.-]+) ([\w.-]+) (\[.+\]) "([^"\r\n]*|[^"\r\n\[]*\[.+\][^"]+|[^"\r\n]+.[^"]+)" (\d{3}) (\d+|-) ("(?:[^"]|\")+)"? ("(?:[^"]|\")+)"?"""
match(pat, target)

# issue #26829
@test map(m -> m.match, eachmatch(r"^$|\S", "ö")) == ["ö"]

# issue #26199
@test map(m -> m.match, eachmatch(r"(\p{L}+)", "")) == [""]
@test map(m -> m.match, eachmatch(r"(\p{L}+)", "Tú lees.")) == ["", "lees"]
@test map(m -> m.match, eachmatch(r"(\p{L}+)", "¿Cuál es tu pregunta?")) == ["Cuál", "es", "tu", "pregunta"]

# Issue 9545 (32 bit)
buf = PipeBuffer()
show(buf, r"")
Expand Down

0 comments on commit 9aedbcb

Please sign in to comment.