mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-12-29 21:31:01 +00:00
only load blobs to check for <?php header for specific drupal file extensions
This commit is contained in:
@@ -135,6 +135,13 @@ module Linguist
|
|||||||
['.png', '.jpg', '.jpeg', '.gif'].include?(extname)
|
['.png', '.jpg', '.jpeg', '.gif'].include?(extname)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Public: Is the blob a possible drupal php file?
|
||||||
|
#
|
||||||
|
# Return true or false
|
||||||
|
def drupal_extname?
|
||||||
|
['.module', '.install', '.test', '.inc'].include?(extname)
|
||||||
|
end
|
||||||
|
|
||||||
MEGABYTE = 1024 * 1024
|
MEGABYTE = 1024 * 1024
|
||||||
|
|
||||||
# Public: Is the blob too big to load?
|
# Public: Is the blob too big to load?
|
||||||
@@ -512,10 +519,13 @@ module Linguist
|
|||||||
|
|
||||||
# Internal: Guess language from the first line.
|
# Internal: Guess language from the first line.
|
||||||
#
|
#
|
||||||
# Look for leading "<?php"
|
# Look for leading "<?php" in Drupal files
|
||||||
#
|
#
|
||||||
# Returns a Language.
|
# Returns a Language.
|
||||||
def first_line_language
|
def first_line_language
|
||||||
|
# Only check files with drupal php extensions
|
||||||
|
return unless drupal_extname?
|
||||||
|
|
||||||
# Fail fast if blob isn't viewable?
|
# Fail fast if blob isn't viewable?
|
||||||
return unless viewable?
|
return unless viewable?
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user