Skip to content

Commit fb69210

Browse files
committed
fix(comments): Check comment object
Signed-off-by: Joas Schilling <[email protected]>
1 parent 1f9687f commit fb69210

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

apps/dav/lib/Comments/EntityCollection.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ public function getId() {
7777
public function getChild($name) {
7878
try {
7979
$comment = $this->commentsManager->get($name);
80+
if ($comment->getObjectType() !== $this->name
81+
|| $comment->getObjectId() !== $this->id) {
82+
throw new NotFound();
83+
}
8084
return new CommentNode(
8185
$this->commentsManager,
8286
$comment,
@@ -130,8 +134,9 @@ public function findChildren($limit = 0, $offset = 0, ?\DateTime $datetime = nul
130134
*/
131135
public function childExists($name) {
132136
try {
133-
$this->commentsManager->get($name);
134-
return true;
137+
$comment = $this->commentsManager->get($name);
138+
return $comment->getObjectType() === $this->name
139+
&& $comment->getObjectId() === $this->id;
135140
} catch (NotFoundException $e) {
136141
return false;
137142
}

lib/private/DB/QueryBuilder/QueryBuilder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ public function orHaving(...$having) {
11171117
* @return $this This QueryBuilder instance.
11181118
*/
11191119
public function orderBy($sort, $order = null) {
1120+
if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) {
1121+
$order = null;
1122+
}
1123+
11201124
$this->queryBuilder->orderBy(
11211125
$this->helper->quoteColumnName($sort),
11221126
$order
@@ -1134,6 +1138,10 @@ public function orderBy($sort, $order = null) {
11341138
* @return $this This QueryBuilder instance.
11351139
*/
11361140
public function addOrderBy($sort, $order = null) {
1141+
if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) {
1142+
$order = null;
1143+
}
1144+
11371145
$this->queryBuilder->addOrderBy(
11381146
$this->helper->quoteColumnName($sort),
11391147
$order

lib/private/DB/QueryBuilder/Sharded/ShardedQueryBuilder.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,13 +276,21 @@ public function setFirstResult($firstResult) {
276276
}
277277

278278
public function addOrderBy($sort, $order = null) {
279-
$this->registerOrder((string)$sort, (string)$order ?? 'ASC');
279+
if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) {
280+
$order = null;
281+
}
282+
283+
$this->registerOrder((string)$sort, (string)($order ?? 'ASC'));
280284
return parent::addOrderBy($sort, $order);
281285
}
282286

283287
public function orderBy($sort, $order = null) {
288+
if ($order !== null && !in_array(strtoupper((string)$order), ['ASC', 'DESC'], true)) {
289+
$order = null;
290+
}
291+
284292
$this->sortList = [];
285-
$this->registerOrder((string)$sort, (string)$order ?? 'ASC');
293+
$this->registerOrder((string)$sort, (string)($order ?? 'ASC'));
286294
return parent::orderBy($sort, $order);
287295
}
288296

0 commit comments

Comments
 (0)