Skip to content

Commit ef6bcdb

Browse files
authored
Fix extra escaping on rule clone
fixes #15023
1 parent 5fbec5a commit ef6bcdb

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/Rule.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3552,8 +3552,6 @@ public function prepareInputForClone($input)
35523552
$input['ranking'] = $nextRanking;
35533553
$input['uuid'] = static::getUuid();
35543554

3555-
$input = Toolbox::addslashes_deep($input);
3556-
35573555
return $input;
35583556
}
35593557

tests/functional/Rule.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,28 @@ public function testClone()
604604
)
605605
)->isIdenticalTo($expected);
606606
}
607+
608+
//rename rule with a quote, then clone
609+
$rules_id = $cloned;
610+
$rule = new \RuleAsset(); //needed to reset last_clone_index...
611+
$this->boolean($rule->update(['id' => $rules_id, 'name' => addslashes("User's assigned")]))->isTrue();
612+
$this->boolean($rule->getFromDB($rules_id))->isTrue();
613+
614+
$cloned = $rule->clone();
615+
$this->integer($cloned)->isGreaterThan($rules_id);
616+
$this->boolean($rule->getFromDB($cloned))->isTrue();
617+
618+
$this->integer($rule->fields['is_active'])->isIdenticalTo(0);
619+
$this->string($rule->fields['name'])->isIdenticalTo("User's assigned (copy)");
620+
621+
foreach ($relations as $relation => $expected) {
622+
$this->integer(
623+
countElementsInTable(
624+
$relation::getTable(),
625+
['rules_id' => $cloned]
626+
)
627+
)->isIdenticalTo($expected);
628+
}
607629
}
608630

609631
public function testRanking()

0 commit comments

Comments
 (0)