]> git.mxchange.org Git - friendica.git/commitdiff
Only allow explicitly known order types through
authorHank Grabowski <hankgrabowski@gmail.com>
Tue, 28 Feb 2023 18:10:45 +0000 (13:10 -0500)
committerHank Grabowski <hankgrabowski@gmail.com>
Tue, 28 Feb 2023 18:10:45 +0000 (13:10 -0500)
src/Module/BaseApi.php

index bfcb95eb2ed2dab56cd7e18051c9bca976c22720..2be5c246a2aee5e8be305f652a8d57791b935677 100644 (file)
@@ -129,7 +129,18 @@ class BaseApi extends BaseModule
                                $condition = DBA::mergeConditions($condition, ["`uri-id` > ?", intval($request['min_id'])]);
                        }
                } else {
-                       $order_field = $requested_order;
+                       switch ($requested_order) {
+                               case TimelineOrderByTypes::RECEIVED:
+                               case TimelineOrderByTypes::CHANGED:
+                               case TimelineOrderByTypes::EDITED:
+                               case TimelineOrderByTypes::CREATED:
+                               case TimelineOrderByTypes::COMMENTED:
+                                       $order_field = $requested_order;
+                                       break;
+                               default:
+                                       throw new \Exception("Unrecognized request order: $requested_order");
+                       }
+
                        if (!empty($request['max_id'])) {
                                $condition = DBA::mergeConditions($condition, ["`$order_field` < ?", DateTimeFormat::convert($request['max_id'], DateTimeFormat::MYSQL)]);
                        }