From e415a1351bf3e7eff0a33574400fa89c0941d9bf Mon Sep 17 00:00:00 2001 From: "Scott J. Goldman" Date: Fri, 31 Aug 2012 22:47:19 -0700 Subject: When testing if a blob is indexable, check size first Otherwise, charlock_holmes will allocate another large binary buffer for testing the encoding, which is a problem if the binary blob is many hundreds of MB large. It'll just fail and crash ruby. --- lib/linguist/blob_helper.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/linguist/blob_helper.rb b/lib/linguist/blob_helper.rb index b2d72f1..fbbaff9 100644 --- a/lib/linguist/blob_helper.rb +++ b/lib/linguist/blob_helper.rb @@ -250,7 +250,9 @@ module Linguist # # Return true or false def indexable? - if binary? + if size > 100 * 1024 + false + elsif binary? false elsif extname == '.txt' true @@ -260,8 +262,6 @@ module Linguist false elsif generated? false - elsif size > 100 * 1024 - false else true end -- cgit v1.2.3