Skip to content

Commit f0b0dae

Browse files
author
jneen
committed
limit number of prompt strings to 20
1 parent 02bf963 commit f0b0dae

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ Rouge/NoBuildingAlternationPatternInRegexp:
6565
- 'lib/rouge/lexers/bicep.rb'
6666
- 'lib/rouge/lexers/cfscript.rb'
6767
- 'lib/rouge/lexers/cmhg.rb'
68-
- 'lib/rouge/lexers/console.rb'
6968
- 'lib/rouge/lexers/crystal.rb'
7069
- 'lib/rouge/lexers/csharp.rb'
7170
- 'lib/rouge/lexers/d.rb'

lib/rouge/lexers/console.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def comment_regex
7575

7676
def end_chars
7777
@end_chars ||= if @prompt.any?
78-
@prompt.reject { |c| c.empty? }
78+
@prompt.reject { |c| c.empty? }.uniq.first(20)
7979
elsif allow_comments?
8080
%w($ > ;)
8181
else
@@ -173,9 +173,13 @@ def prompt_prefix_regex
173173
end
174174

175175
def prompt_regex
176+
# [jneen] these characters can come from user input. They are escaped here,
177+
# and we limit the user to 20.
178+
#rubocop:disable Rouge/NoBuildingAlternationPatternInRegexp
176179
@prompt_regex ||= begin
177180
/^#{prompt_prefix_regex}(?:#{end_chars.map { |c| Regexp.escape(c) }.join('|')})/
178181
end
182+
#rubocop:enable Rouge/NoBuildingAlternationPatternInRegexp
179183
end
180184

181185
def stream_tokens(input, &output)

0 commit comments

Comments
 (0)