Skip to content

Commit

Permalink
Tidy up of security file ignoring.
Browse files Browse the repository at this point in the history
Freeze the array.
Improve the comments.
Change the content of the test file to match the actual Arch Linux file.
  • Loading branch information
philr committed Jul 17, 2022
1 parent 6a4766e commit d2883cf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
40 changes: 22 additions & 18 deletions lib/tzinfo/data_sources/zoneinfo_data_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,28 @@ 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']
# Files in the top level zoneinfo directory that will be excluded from
# the list of available time zones:
#
# - +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 the Arch Linux 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'
].freeze
private_constant :EXCLUDED_FILENAMES

# Paths to be checked to find the system zoneinfo directory.
Expand Down
6 changes: 3 additions & 3 deletions test/data_sources/tc_zoneinfo_data_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1083,8 +1083,8 @@ def test_timezone_identifiers_ignored_src_directory
end

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

Dir.mktmpdir('tzinfo_test') do |dir|
FileUtils.touch(File.join(dir, 'zone.tab'))
Expand All @@ -1093,7 +1093,7 @@ def test_timezone_identifiers_ignored_security_file

File.open(File.join(dir, 'SECURITY'), 'w') do |f|
f.binmode
f.write("2013a\n")
f.write("Please report any sensitive security-related bugs...\n")
end

data_source = ZoneinfoDataSource.new(dir)
Expand Down

0 comments on commit d2883cf

Please sign in to comment.