mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-31 14:36:18 +00:00
Add Blob#vendored?
This commit is contained in:
@@ -3,6 +3,7 @@ require 'linguist/mime'
|
|||||||
require 'linguist/pathname'
|
require 'linguist/pathname'
|
||||||
|
|
||||||
require 'escape_utils'
|
require 'escape_utils'
|
||||||
|
require 'yaml'
|
||||||
|
|
||||||
module Linguist
|
module Linguist
|
||||||
module BlobHelper
|
module BlobHelper
|
||||||
@@ -65,6 +66,13 @@ module Linguist
|
|||||||
['.xib', '.nib', '.pbxproj'].include?(pathname.extname)
|
['.xib', '.nib', '.pbxproj'].include?(pathname.extname)
|
||||||
end
|
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
|
# 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
|
# 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
|
# plugin ignores the response content type and treats any URL as flash
|
||||||
|
|||||||
27
lib/linguist/vendor.yml
Normal file
27
lib/linguist/vendor.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
- yui
|
||||||
|
- tiny_mce
|
||||||
|
- ckeditor
|
||||||
|
- redbox
|
||||||
|
- active_scaffold
|
||||||
|
- rico_corner
|
||||||
|
- code_highlighter
|
||||||
|
- vendor
|
||||||
|
- bundle
|
||||||
|
- node_modules
|
||||||
|
- cache
|
||||||
|
- assets
|
||||||
|
- bookends
|
||||||
|
- dojo
|
||||||
|
- extjs
|
||||||
|
- sencha
|
||||||
|
- mochikit
|
||||||
|
- prototype(.*)\.js
|
||||||
|
- mootools\.js
|
||||||
|
- jquery([^.]*)(\.min)?\.js
|
||||||
|
- jquery\-\d\.\d\.\d(\.min)?\.js
|
||||||
|
- effects\.js
|
||||||
|
- controls\.js
|
||||||
|
- dragdrop\.js
|
||||||
|
- fabfile\.py
|
||||||
|
- less([^.]*)(\.min)?\.js
|
||||||
|
- less\-\d+\.\d+\.\d+(\.min)?\.js
|
||||||
@@ -114,6 +114,19 @@ class TestBlob < Test::Unit::TestCase
|
|||||||
assert blob("project.pbxproj").generated?
|
assert blob("project.pbxproj").generated?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_vendored
|
||||||
|
assert !blob("README").vendored?
|
||||||
|
|
||||||
|
assert blob("node_modules/coffee-script/lib/coffee-script.js").vendored?
|
||||||
|
assert blob("vendor/plugins/will_paginate/lib/will_paginate.rb").vendored?
|
||||||
|
|
||||||
|
assert blob("public/javascripts/jquery.js").vendored?
|
||||||
|
assert blob("public/javascripts/prototype.js").vendored?
|
||||||
|
assert blob("public/javascripts/effects.js").vendored?
|
||||||
|
assert blob("public/javascripts/controls.js").vendored?
|
||||||
|
assert blob("public/javascripts/dragdrop.js").vendored?
|
||||||
|
end
|
||||||
|
|
||||||
def test_language
|
def test_language
|
||||||
assert_equal Language['Ruby'], blob("foo.rb").language
|
assert_equal Language['Ruby'], blob("foo.rb").language
|
||||||
assert_equal Language['Ruby'], blob("script.rb").language
|
assert_equal Language['Ruby'], blob("script.rb").language
|
||||||
|
|||||||
Reference in New Issue
Block a user