-
Notifications
You must be signed in to change notification settings - Fork 103
Validate schedule-for-stop date before the agency lookup #1385
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,6 +107,14 @@ func ValidateDate(date string) error { | |
| return nil | ||
| } | ||
|
|
||
| // ValidateServiceDate reports whether a service date parameter is parseable, in either | ||
| // of the forms ParseDate accepts. Handlers use it to reject a malformed date before | ||
| // looking up the agency whose timezone ParseDate then resolves the date against. | ||
| func ValidateServiceDate(date string) error { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| _, err := ParseDate(date, time.UTC) | ||
| return err | ||
| } | ||
|
|
||
| // SanitizeInput removes HTML tags and other potentially dangerous content | ||
| func SanitizeInput(input string) string { | ||
| // Remove HTML tags | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment ("only fails on an unusable agency timezone") is inaccurate, and the branch below it looks unreachable now.
ValidateServiceDate(line 36) already runsParseDate(dateParam, time.UTC)and returns 400 on any format/bounds failure; neither ofParseDate's two success paths depends on thelocargument for success/failure, so onceValidateServiceDatehas succeeded,ParseDate(dateParam, loc)here can't fail for any validloc. A bad agency timezone is also already caught earlier byloadAgencyLocation(lines 48-52), before this second parse runs. Since this branch appears dead, could it be removed (or the comment corrected if there's a case I'm missing)?