Skip to content

Commit 279f6d9

Browse files
committed
Prevent character literals spanning lines
The single-quote character literal regex was using `[^']*` which would match any character including newlines. This caused character literals to incorrectly span multiple lines when there were unmatched quotes in the input.
1 parent 92202ab commit 279f6d9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/rouge/lexers/crystal.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def self.detect?(text)
8080
rule %r/\b[\p{Ll}_]\p{Word}*?[?!]?:\s+/, Str::Symbol, :expr_start
8181
rule %r/"/, Str::Double, :simple_string
8282
rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
83-
rule %r/(')(\\u[a-fA-F0-9]{4}|\\u\{[a-fA-F0-9]{1,6}\}|\\[abefnrtv])?(\\\\|\\'|[^'])*(')/ do
83+
rule %r/(')(\\u[a-fA-F0-9]{4}|\\u\{[a-fA-F0-9]{1,6}\}|\\[abefnrtv])?(\\\\|\\'|[^'\n])*(')/ do
8484
groups Str::Single, Str::Escape, Str::Single, Str::Single
8585
end
8686
end

0 commit comments

Comments
 (0)