From 8a5b5a71c8157987ee1d7dc8e071365778e4fd99 Mon Sep 17 00:00:00 2001 From: Nicholas Myers <32116122+NicholasMy@users.noreply.github.com> Date: Mon, 17 Feb 2025 12:38:56 -0500 Subject: [PATCH 1/2] Fix viewing GitHub submissions (cherry picked from commit 78f79335407e08172c495fb74aedae5bfc9666ef) --- lib/archive.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/archive.rb b/lib/archive.rb index 675c207ff..2dc6ad0a5 100644 --- a/lib/archive.rb +++ b/lib/archive.rb @@ -71,7 +71,7 @@ def self.sanitize_directories(files) # edge case for removing "./" from pathnames if file[:pathname].include?("./") - file[:pathname] = File.cleanpath(file[:pathname], rel_root = true).gsub("..", "__PARENT__") + file[:pathname] = Pathname.new(file[:pathname]).cleanpath.to_s.gsub("..", "__PARENT__") end if(file[:directory]) From 8930bbed31ea7d6c1f3cfb83294264ab74d40798 Mon Sep 17 00:00:00 2001 From: Nicholas Myers <32116122+NicholasMy@users.noreply.github.com> Date: Thu, 27 Mar 2025 11:30:40 -0400 Subject: [PATCH 2/2] Validate assessment dates are compatible with MySQL TIMESTAMP type --- app/models/assessment.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/models/assessment.rb b/app/models/assessment.rb index 472d804ff..26bdaa413 100755 --- a/app/models/assessment.rb +++ b/app/models/assessment.rb @@ -24,6 +24,7 @@ class Assessment < ApplicationRecord validates :name, format: { with: /\A[^0-9].*/, message: "can't have leading numeral" } validates :display_name, length: { minimum: 1 } validate :verify_dates_order + validate :verify_dates_valid_for_mysql validate :handin_directory_and_filename_or_disable_handins, if: :active? validate :handin_directory_exists_or_disable_handins, if: :active? validate :valid_handout @@ -676,6 +677,21 @@ def verify_dates_order errors.add :end_at, "must be after the due date" if due_at > end_at end + def verify_dates_valid_for_mysql + # MySQL TIMESTAMP range is 1970-01-01 00:00:01 to 2038-01-19 03:14:07 + min_time = Time.at(1).utc # 1970-01-01 00:00:01 UTC + max_time = Time.at(2**31 - 1).utc # 2038-01-19 03:14:07 UTC + if start_at < min_time || start_at > max_time + errors.add :start_at, "must be between 1970-01-01 and 2038-01-19" + end + if due_at < min_time || due_at > max_time + errors.add :due_at, "must be between 1970-01-01 and 2038-01-19" + end + if end_at < min_time || end_at > max_time + errors.add :end_at, "must be between 1970-01-01 and 2038-01-19" + end + end + def handin_directory_and_filename_or_disable_handins if disable_handins? true