summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKornelius Kalnbach <murphy@rubychan.de>2013-07-20 18:12:04 +0200
committerKornelius Kalnbach <murphy@rubychan.de>2013-07-20 18:12:04 +0200
commit5c23a731ca55729fc65630eca3b37a5b1a71e5b1 (patch)
tree97045ac6fa9544a1e0f168b9a02c7b53b0c4e452
parent59ca07b0d1a1710ab729636ea00de4b638f56110 (diff)
downloadcoderay-5c23a731ca55729fc65630eca3b37a5b1a71e5b1.tar.gz
mark possibly problematic spots with FIXME
-rw-r--r--lib/coderay/encoders/html.rb2
-rw-r--r--lib/coderay/encoders/html/css.rb2
-rw-r--r--lib/coderay/helpers/file_type.rb1
-rw-r--r--lib/coderay/helpers/plugin.rb1
-rw-r--r--lib/coderay/scanners/debug.rb2
-rw-r--r--lib/coderay/scanners/diff.rb1
-rw-r--r--lib/coderay/scanners/python.rb3
-rw-r--r--lib/coderay/scanners/raydebug.rb2
-rw-r--r--lib/coderay/scanners/ruby/string_state.rb1
9 files changed, 15 insertions, 0 deletions
diff --git a/lib/coderay/encoders/html.rb b/lib/coderay/encoders/html.rb
index 20f2409..6dd231a 100644
--- a/lib/coderay/encoders/html.rb
+++ b/lib/coderay/encoders/html.rb
@@ -142,6 +142,7 @@ module Encoders
HTML_ESCAPE = make_html_escape_hash
HTML_ESCAPE_PATTERN = /[\t"&><\0-\x8\xB-\x1F]/
+ # FIXME: cache attack
TOKEN_KIND_TO_INFO = Hash.new do |h, kind|
h[kind] = kind.to_s.gsub(/_/, ' ').gsub(/\b\w/) { $&.capitalize }
end
@@ -284,6 +285,7 @@ module Encoders
end
def make_span_for_kinds method, hint
+ # FIXME: cache attack
Hash.new do |h, kinds|
h[kinds.is_a?(Symbol) ? kinds : kinds.dup] = begin
css_class = css_class_for_kinds(kinds)
diff --git a/lib/coderay/encoders/html/css.rb b/lib/coderay/encoders/html/css.rb
index 164d7f8..de98f0e 100644
--- a/lib/coderay/encoders/html/css.rb
+++ b/lib/coderay/encoders/html/css.rb
@@ -21,6 +21,7 @@ module Encoders
end
def get_style_for_css_classes css_classes
+ # FIXME: cache attack
cl = @styles[css_classes.first]
return '' unless cl
style = ''
@@ -52,6 +53,7 @@ module Encoders
for selector in selectors.split(',')
classes = selector.scan(/[-\w]+/)
cl = classes.pop
+ # FIXME: cache attack
@styles[cl] ||= Hash.new
@styles[cl][classes] = style.to_s.strip.delete(' ').chomp(';')
end
diff --git a/lib/coderay/helpers/file_type.rb b/lib/coderay/helpers/file_type.rb
index 5e3a1e7..e8a7b75 100644
--- a/lib/coderay/helpers/file_type.rb
+++ b/lib/coderay/helpers/file_type.rb
@@ -68,6 +68,7 @@ module CodeRay
File.open filename, 'r' do |f|
if first_line = f.gets
if type = first_line[TypeFromShebang]
+ # FIXME: cache attack
type.to_sym
end
end
diff --git a/lib/coderay/helpers/plugin.rb b/lib/coderay/helpers/plugin.rb
index d14c5a9..3a38bfd 100644
--- a/lib/coderay/helpers/plugin.rb
+++ b/lib/coderay/helpers/plugin.rb
@@ -207,6 +207,7 @@ module CodeRay
id
elsif id.is_a? String
if id[/\w+/] == id
+ # FIXME: cache attack
id.downcase.to_sym
else
raise ArgumentError, "Invalid id given: #{id}"
diff --git a/lib/coderay/scanners/debug.rb b/lib/coderay/scanners/debug.rb
index 566bfa7..9d10864 100644
--- a/lib/coderay/scanners/debug.rb
+++ b/lib/coderay/scanners/debug.rb
@@ -21,6 +21,7 @@ module Scanners
encoder.text_token match, :space
elsif match = scan(/ (\w+) \( ( [^\)\\]* ( \\. [^\)\\]* )* ) \)? /x)
+ # FIXME: cache attack
kind = self[1].to_sym
match = self[2].gsub(/\\(.)/m, '\1')
unless TokenKinds.has_key? kind
@@ -30,6 +31,7 @@ module Scanners
encoder.text_token match, kind
elsif match = scan(/ (\w+) ([<\[]) /x)
+ # FIXME: cache attack
kind = self[1].to_sym
opened_tokens << kind
case self[2]
diff --git a/lib/coderay/scanners/diff.rb b/lib/coderay/scanners/diff.rb
index fd1aed6..836fa41 100644
--- a/lib/coderay/scanners/diff.rb
+++ b/lib/coderay/scanners/diff.rb
@@ -21,6 +21,7 @@ module Scanners
line_kind = nil
state = :initial
deleted_lines_count = 0
+ # FIXME: cache attack
scanners = Hash.new do |h, lang|
h[lang] = Scanners[lang].new '', :keep_tokens => true, :keep_state => true
end
diff --git a/lib/coderay/scanners/python.rb b/lib/coderay/scanners/python.rb
index 09c8b6e..23630f9 100644
--- a/lib/coderay/scanners/python.rb
+++ b/lib/coderay/scanners/python.rb
@@ -75,10 +75,12 @@ module Scanners
<<=? | >>=? | [<>=]=? | != # comparison and assignment
/x # :nodoc:
+ # FIXME: cache attack
STRING_DELIMITER_REGEXP = Hash.new { |h, delimiter|
h[delimiter] = Regexp.union delimiter # :nodoc:
}
+ # FIXME: cache attack
STRING_CONTENT_REGEXP = Hash.new { |h, delimiter|
h[delimiter] = / [^\\\n]+? (?= \\ | $ | #{Regexp.escape(delimiter)} ) /x # :nodoc:
}
@@ -183,6 +185,7 @@ module Scanners
kind = :ident
elsif kind == :keyword
state = DEF_NEW_STATE[match]
+ # FIXME: cache attack
from_import_state << match.to_sym if state == :include_expected
end
encoder.text_token match, kind
diff --git a/lib/coderay/scanners/raydebug.rb b/lib/coderay/scanners/raydebug.rb
index d39d962..ca35de0 100644
--- a/lib/coderay/scanners/raydebug.rb
+++ b/lib/coderay/scanners/raydebug.rb
@@ -26,6 +26,7 @@ module Scanners
encoder.text_token kind, :class
encoder.text_token '(', :operator
match = self[2]
+ # FIXME: cache attack
encoder.text_token match, kind.to_sym unless match.empty?
encoder.text_token match, :operator if match = scan(/\)/)
@@ -39,6 +40,7 @@ module Scanners
else
raise 'CodeRay bug: This case should not be reached.'
end
+ # FIXME: cache attack
kind = kind.to_sym
opened_tokens << kind
encoder.begin_group kind
diff --git a/lib/coderay/scanners/ruby/string_state.rb b/lib/coderay/scanners/ruby/string_state.rb
index 2f398d1..fe37d07 100644
--- a/lib/coderay/scanners/ruby/string_state.rb
+++ b/lib/coderay/scanners/ruby/string_state.rb
@@ -14,6 +14,7 @@ module Scanners
{ }
] ].each { |k,v| k.freeze; v.freeze } # debug, if I try to change it with <<
+ # FIXME: cache attack
STRING_PATTERN = Hash.new do |h, k|
delim, interpreted = *k
# delim = delim.dup # workaround for old Ruby