Skip to content

Commit 6f810c6

Browse files
committed
Added whitelist to setQueryOption
1 parent 7429e5a commit 6f810c6

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

MysqliDb.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,19 @@ public function query($query, $numRows = null)
278278
* @return MysqliDb
279279
*/
280280
public function setQueryOption ($options) {
281-
if (is_array ($options))
282-
$this->_queryOptions = array_merge ($this->_queryOptions, $options);
283-
else
284-
$this->_queryOptions[] = $options;
281+
$allowedOptions = Array ('ALL','DISTINCT','DISTINCTROW','HIGH_PRIORITY','STRAIGHT_JOIN','SQL_SMALL_RESULT',
282+
'SQL_BIG_RESULT','SQL_BUFFER_RESULT','SQL_CACHE','SQL_NO_CACHE', 'SQL_CALC_FOUND_ROWS',
283+
'LOW_PRIORITY','IGNORE','QUICK');
284+
if (!is_array ($options))
285+
$options = Array ($options);
286+
287+
foreach ($options as $option) {
288+
$option = strtoupper ($option);
289+
if (!in_array ($option, $allowedOptions))
290+
die ('Wrong query option: '.$option);
291+
292+
$this->_queryOptions[] = $option;
293+
}
285294

286295
return $this;
287296
}

0 commit comments

Comments
 (0)