Skip to content

Commit 8eb2ae2

Browse files
committed
Fixed parsing of escaped characters in strings
1 parent 26fc790 commit 8eb2ae2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/rdoc/ruby_lex.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,8 @@ def identify_string(ltype, quoted = ltype, type = nil)
11881188
if %w[' /].include? @ltype then
11891189
case ch = getc
11901190
when "\\", "\n", "'"
1191+
when @ltype
1192+
str << ch
11911193
else
11921194
ungetc
11931195
end

test/test_rdoc_ruby_lex.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ def test_class_tokenize_regexp_backref
149149
assert_equal expected, tokens
150150
end
151151

152+
def test_class_tokenize_regexp_escape
153+
tokens = RDoc::RubyLex.tokenize "/\\//", nil
154+
155+
expected = [
156+
@TK::TkREGEXP.new( 0, 1, 0, "/\\//"),
157+
@TK::TkNL .new( 4, 1, 4, "\n"),
158+
]
159+
160+
assert_equal expected, tokens
161+
end
162+
152163
def test_class_tokenize_string
153164
tokens = RDoc::RubyLex.tokenize "'hi'", nil
154165

0 commit comments

Comments
 (0)