We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ee30738 commit e254606Copy full SHA for e254606
lib/coderay/scanners/raydebug.rb
@@ -1,3 +1,5 @@
1
+require 'set'
2
+
3
module CodeRay
4
module Scanners
5
@@ -12,6 +14,11 @@ class Raydebug < Scanner
12
14
13
15
protected
16
17
+ def setup
18
+ super
19
+ @known_token_kinds = TokenKinds.keys.map(&:to_s).to_set
20
+ end
21
22
def scan_tokens encoder, options
23
24
opened_tokens = []
@@ -26,8 +33,13 @@ def scan_tokens encoder, options
26
33
encoder.text_token kind, :class
27
34
encoder.text_token '(', :operator
28
35
match = self[2]
29
- # FIXME: cache attack
30
- encoder.text_token match, kind.to_sym unless match.empty?
36
+ unless match.empty?
37
+ if @known_token_kinds.include? kind
38
+ encoder.text_token match, kind.to_sym
39
+ else
40
+ encoder.text_token match, :plain
41
42
31
43
encoder.text_token match, :operator if match = scan(/\)/)
32
44
45
elsif match = scan(/ (\w+) ([<\[]) /x)
0 commit comments