Make colorize safer:

- don't try to colorize blobs that have a high ratio of
    long lines -- these are most likely minified files or something else
    strange that will blow up Pygments.rb
  - re github/github#3938
This commit is contained in:
Rob Sanheim
2012-05-21 11:31:21 -05:00
parent 7a84cfc24e
commit 1c7b8ebe71
3 changed files with 55 additions and 3 deletions

View File

@@ -513,7 +513,12 @@ class TestBlob < Test::Unit::TestCase
HTML
end
def test_colorize_doesnt_skip_minified_files
assert blob("jquery-1.6.1.min.js").colorize
def test_colorize_does_skip_minified_files
assert_nil blob("jquery-1.6.1.min.js").colorize
end
# Pygments.rb was taking exceeding long on this particular file
def test_colorize_doesnt_blow_up_with_files_with_high_ratio_of_long_lines
assert_nil blob("steelseries-min.js").colorize
end
end