Add Blob#vendored?

This commit is contained in:
Joshua Peek
2011-05-21 21:09:37 -05:00
parent 6f1f71ae23
commit e02f745cfc
3 changed files with 48 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ require 'linguist/mime'
require 'linguist/pathname'
require 'escape_utils'
require 'yaml'
module Linguist
module BlobHelper
@@ -65,6 +66,13 @@ module Linguist
['.xib', '.nib', '.pbxproj'].include?(pathname.extname)
end
vendored_paths = YAML.load_file(File.expand_path("../vendor.yml", __FILE__))
VendoredRegexp = Regexp.new(vendored_paths.join('|'))
def vendored?
name =~ VendoredRegexp
end
# Determine if the blob contains bad content that can be used for various
# cross site attacks. Right now this is limited to flash files -- the flash
# plugin ignores the response content type and treats any URL as flash