Skip to content

Commit 44be6de

Browse files
committed
fix(targetticket): possible SQL error
With a form configured to set location of a target ticket from a question, changing the question type to a text field causes attempt to set location from a string instead if an ID. If the string contains a single quote, then the INSERT query is broken. This check the value is an integer. If not, lets ignore the value. May need to lock questions when they are linked to a target.
1 parent 34b230f commit 44be6de

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

inc/targetticket.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@ public function save(PluginFormcreatorFormAnswer $formanswer) {
953953
protected function setTargetLocation($data, $formanswer) {
954954
global $DB;
955955

956+
$location = null;
956957
switch ($this->fields['location_rule']) {
957958
case self::LOCATION_RULE_ANSWER:
958959
$location = $DB->request([
@@ -963,13 +964,13 @@ protected function setTargetLocation($data, $formanswer) {
963964
'plugin_formcreator_questions_id' => $this->fields['location_question']
964965
]
965966
])->current();
966-
$location = $location['answer'];
967+
if (ctype_digit($location['answer'])) {
968+
$location = $location['answer'];
969+
}
967970
break;
968971
case self::LOCATION_RULE_SPECIFIC:
969972
$location = $this->fields['location_question'];
970973
break;
971-
default:
972-
$location = null;
973974
}
974975
if (!is_null($location)) {
975976
$data['locations_id'] = $location;

0 commit comments

Comments
 (0)