Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2680705
D25825.1734616030.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
D25825.1734616030.diff
View Options
diff --git a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
--- a/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
+++ b/src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
@@ -485,6 +485,12 @@
->setHeader($header);
}
+ /**
+ * @param string|null $range_start Epoch
+ * @param string|null $range_end Epoch
+ * @param string $display View, such as "month" or "day"
+ * @return array<string|int, string|int, string|int> YYYY, M, D
+ */
private function getDisplayYearAndMonthAndDay(
$range_start,
$range_end,
@@ -527,7 +533,7 @@
/**
* @param PhabricatorSavedQuery $saved
- * @return AphrontFormDateControlValue
+ * @return AphrontFormDateControlValue Query date range start
*/
private function getQueryDateFrom(PhabricatorSavedQuery $saved) {
if ($this->calendarYear && $this->calendarMonth) {
@@ -544,11 +550,40 @@
));
}
- return $this->getQueryDate($saved, 'rangeStart');
+ $date = $this->getQueryDate($saved, 'rangeStart');
+ $this->validateDate($date);
+
+ return $date;
}
+ /**
+ * @param PhabricatorSavedQuery $saved
+ * @return AphrontFormDateControlValue Query date range end
+ */
private function getQueryDateTo(PhabricatorSavedQuery $saved) {
- return $this->getQueryDate($saved, 'rangeEnd');
+ $date = $this->getQueryDate($saved, 'rangeEnd');
+ $this->validateDate($date);
+ return $date;
+ }
+
+ /**
+ * Validate the user provided date and time value(s) by calling
+ * @{class:AphrontFormDateControlValue}::isValid().
+ * Throw a DateMalformedStringException if invalid.
+ *
+ * @param AphrontFormDateControlValue $date
+ * @return void
+ */
+ private function validateDate(AphrontFormDateControlValue $date) {
+ if (!$date->isValid()) {
+ if (version_compare(phpversion(), '8.3.0', '>')) {
+ throw new DateMalformedStringException(
+ pht('Invalid date or time value set as query value.'));
+ } else {
+ throw new Exception(
+ pht('Invalid date or time value set as query value.'));
+ }
+ }
}
private function getQueryDate(PhabricatorSavedQuery $saved, $key) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 13:47 (20 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015082
Default Alt Text
D25825.1734616030.diff (2 KB)
Attached To
Mode
D25825: Validate some user provided calendar query range dates
Attached
Detach File
Event Timeline
Log In to Comment