File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change
1
+ require 'set'
2
+
1
3
module CodeRay
2
4
module Scanners
3
5
@@ -12,6 +14,11 @@ class Raydebug < Scanner
12
14
13
15
protected
14
16
17
+ def setup
18
+ super
19
+ @known_token_kinds = TokenKinds . keys . map ( &:to_s ) . to_set
20
+ end
21
+
15
22
def scan_tokens encoder , options
16
23
17
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
+ end
42
+ end
31
43
encoder . text_token match , :operator if match = scan ( /\) / )
32
44
33
45
elsif match = scan ( / (\w +) ([<\[ ]) /x )
You can’t perform that action at this time.
0 commit comments