simple_calendar 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6648d821f8f764b1abac6ece0cdbe575a53696cb85c8057977505f3c61b26aa5
4
- data.tar.gz: dacfc17b693c75f56cf9d104cc827ef9026980356a803c287931158816b1d510
3
+ metadata.gz: a1789f19b1f7e2ff7dfe9734bd1ef5a4ff45a76204c52f63155854fca76cc033
4
+ data.tar.gz: 7128d7d5d2f8a65d9377aafdd828edd8e30d8e7a2f56ca0f7ca7c95a81bb5928
5
5
  SHA512:
6
- metadata.gz: 9050ae89085e40c8b3bb7af30c93ff913ea0cc5a6a1d07e1bee28c3126857c40b7ef28b58e1f8529e6712d941af4dba9aa73cf56d9b400bde172cf4b684e958a
7
- data.tar.gz: d71601a640b7bcc4bba127b7b5ec3fa17ced71a481e15e280e2a39ed1f7306a535adfecd6fdabdb1ec4b74e5045828d55e637216043b1d08062bc07a9f63be6f
6
+ metadata.gz: acf827741610c4a259770cdf52da653156816c7bb75c31a1228b543ebcf5761b66c72b3594da14dd680c542947fd2b018629d0ccd089d7c685ef21704c30413a
7
+ data.tar.gz: 22f93c93d076483140e00c79ed33a8e194d3d1ad3624513fa7e9959be6107e5d1a7c5b9909464b98a1fbecfd3ec0a918293d51d12969aa9ff06f810992b6c051
@@ -2,7 +2,14 @@ require "rails"
2
2
 
3
3
  module SimpleCalendar
4
4
  class Calendar
5
- PARAM_KEY_BLACKLIST = :authenticity_token, :commit, :utf8, :_method, :script_name
5
+ # Besides form noise, this drops keys url_for treats as URL options instead of query
6
+ # params. Passing them through from the request would let a crafted link change the
7
+ # host, protocol, route, etc. of the Previous / Today / Next links (open redirect,
8
+ # javascript: XSS, 500s).
9
+ PARAM_KEY_BLACKLIST = :authenticity_token, :commit, :utf8, :_method, :script_name,
10
+ :host, :protocol, :port, :subdomain, :domain, :tld_length, :trailing_slash, :anchor,
11
+ :params, :only_path, :original_script_name, :relative_url_root, :user, :password,
12
+ :use_route, :_recall
6
13
 
7
14
  attr_accessor :view_context, :options
8
15
 
@@ -125,7 +132,7 @@ module SimpleCalendar
125
132
  if options.has_key?(:start_date)
126
133
  options.fetch(:start_date).to_date
127
134
  else
128
- view_context.params.fetch(start_date_param, Date.current).to_date
135
+ start_date_from_params || Date.current
129
136
  end
130
137
  end
131
138
 
@@ -136,5 +143,13 @@ module SimpleCalendar
136
143
  def additional_days
137
144
  options.fetch(:number_of_days, 4) - 1
138
145
  end
146
+
147
+ private
148
+
149
+ def start_date_from_params
150
+ view_context.params[start_date_param].try(:to_date)
151
+ rescue ArgumentError # Date::Error inherits from ArgumentError
152
+ nil
153
+ end
139
154
  end
140
155
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleCalendar
2
- VERSION = "3.1.0"
2
+ VERSION = "3.1.2"
3
3
  end
@@ -1,16 +1,16 @@
1
1
  module SimpleCalendar
2
2
  class WeekCalendar < SimpleCalendar::Calendar
3
3
  def week_number
4
- format = (Date.beginning_of_week == :sunday) ? "%U" : "%V"
5
- start_date.beginning_of_week.strftime(format).to_i
4
+ week_number_for(start_date)
6
5
  end
7
6
 
8
7
  def number_of_weeks
9
8
  options.fetch(:number_of_weeks, 1)
10
9
  end
11
10
 
11
+ # Computed from the date, not week_number + n, so it wraps across a year boundary.
12
12
  def end_week
13
- week_number + number_of_weeks - 1
13
+ week_number_for(date_range.last)
14
14
  end
15
15
 
16
16
  def date_range
@@ -23,5 +23,12 @@ module SimpleCalendar
23
23
  def url_for_previous_view
24
24
  view_context.url_for(@params.merge(start_date_param => (date_range.first - 1.day).iso8601))
25
25
  end
26
+
27
+ private
28
+
29
+ def week_number_for(date)
30
+ format = (Date.beginning_of_week == :sunday) ? "%U" : "%V"
31
+ date.beginning_of_week.strftime(format).to_i
32
+ end
26
33
  end
27
34
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_calendar
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
+ autorequire:
8
9
  bindir: bin
9
10
  cert_chain: []
10
- date: 2025-01-09 00:00:00.000000000 Z
11
+ date: 2026-10-12 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: rails
@@ -51,6 +52,7 @@ metadata:
51
52
  homepage_uri: https://github.com/excid3/simple_calendar
52
53
  source_code_uri: https://github.com/excid3/simple_calendar
53
54
  changelog_uri: https://github.com/excid3/simple_calendar/blob/main/CHANGELOG.md
55
+ post_install_message:
54
56
  rdoc_options: []
55
57
  require_paths:
56
58
  - lib
@@ -65,7 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
67
  - !ruby/object:Gem::Version
66
68
  version: '0'
67
69
  requirements: []
68
- rubygems_version: 3.6.2
70
+ rubygems_version: 3.5.22
71
+ signing_key:
69
72
  specification_version: 4
70
73
  summary: A simple Rails calendar
71
74
  test_files: []