Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ignore SECURITY file for Arch tzdata package #133

Merged
merged 1 commit into from Jul 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 21 additions & 9 deletions lib/tzinfo/data_sources/zoneinfo_data_source.rb
Expand Up @@ -78,6 +78,26 @@ class ZoneinfoDataSource < DataSource
DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH = ['/usr/share/misc/iso3166.tab', '/usr/share/misc/iso3166'].freeze
private_constant :DEFAULT_ALTERNATE_ISO3166_TAB_SEARCH_PATH

# Ignoring particular files:
# +VERSION is included on Mac OS X.
# leapseconds is a list of leap seconds.
# localtime is the current local timezone (may be a link).
# posix, posixrules and right are directories containing other versions of
# the zoneinfo files.
# SECURITY is included in Arch tzdata package.
# src is a directory containing the tzdata source included on Solaris.
# timeconfig is a symlink included on Slackware.
EXCLUDED_FILENAMES = ['+VERSION',
'leapseconds',
'localtime',
'posix',
'posixrules',
'right',
'SECURITY',
'src',
'timeconfig']
private_constant :EXCLUDED_FILENAMES

# Paths to be checked to find the system zoneinfo directory.
#
# @private
Expand Down Expand Up @@ -394,15 +414,7 @@ def find_zoneinfo_dir
def load_timezone_identifiers
index = []

# Ignoring particular files:
# +VERSION is included on Mac OS X.
# leapseconds is a list of leap seconds.
# localtime is the current local timezone (may be a link).
# posix, posixrules and right are directories containing other versions of the zoneinfo files.
# src is a directory containing the tzdata source included on Solaris.
# timeconfig is a symlink included on Slackware.

enum_timezones([], ['+VERSION', 'leapseconds', 'localtime', 'posix', 'posixrules', 'right', 'src', 'timeconfig']) do |identifier|
enum_timezones([], EXCLUDED_FILENAMES) do |identifier|
index << identifier.join('/').freeze
end

Expand Down
19 changes: 19 additions & 0 deletions test/data_sources/tc_zoneinfo_data_source.rb
Expand Up @@ -1082,6 +1082,25 @@ def test_timezone_identifiers_ignored_src_directory
end
end

def test_timezone_identifiers_ignored_security_file
# Arch tzdata package includes a file named SECURITY giving instructions
# to report any security-related bug.

Dir.mktmpdir('tzinfo_test') do |dir|
FileUtils.touch(File.join(dir, 'zone.tab'))
FileUtils.touch(File.join(dir, 'iso3166.tab'))
FileUtils.cp(File.join(@data_source.zoneinfo_dir, 'EST'), File.join(dir, 'EST'))

File.open(File.join(dir, 'SECURITY'), 'w') do |f|
f.binmode
f.write("2013a\n")
end

data_source = ZoneinfoDataSource.new(dir)
assert_equal(['EST'], data_source.timezone_identifiers)
end
end

def test_load_country_info
info = @data_source.send(:load_country_info, 'GB')
assert_equal('GB', info.code)
Expand Down