Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unbalanced parenthesis crash in Common Lisp lexer #1129

Merged
merged 1 commit into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rouge/lexers/common_lisp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class complex concatenated-stream cons echo-stream file-stream

rule /\(/, Punctuation, :root
rule /\)/, Punctuation do
if stack.empty?
if stack.size == 1
token Error
else
token Punctuation
Expand Down
8 changes: 8 additions & 0 deletions spec/lexers/common_lisp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@
assert_guess :mimetype => 'text/x-common-lisp'
end
end

describe 'lexing' do
include Support::Lexing

it 'does not crash on unbalanced parentheses' do
subject.lex(")\n").to_a
end
end
end
3 changes: 3 additions & 0 deletions spec/visual/samples/common_lisp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#nil (commented (form ftw))

; Unmatched closing parenthesis
)

;;;; TYPEP und Verwandtes
;;;; Michael Stoll, 21. 10. 1988
;;;; Bruno Haible, 10.6.1989
Expand Down