-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
Hello,
We encountered a bug after defining a regex segment with the following regex ^\d*[13579]$, after a lot of investigation we found that the code cast the expression as an int, making the regex useless and hazardous. We added dumps to the code in order to help you understand the bug.
class SegmentConditionModel
{
public function matchesTraitValue($traitValue): bool
{
$condition = false;
$castedValue = $this->value;
$traitValueType = gettype($traitValue);
dump($castedValue); // "^\d*[13579]$"
dump($traitValueType); // "integer"
dump($this->operator); "REGEX"
if ($traitValueType == 'boolean') {
$castedValue = filter_var($castedValue, FILTER_VALIDATE_BOOLEAN);
} elseif ($this->operator === SegmentConditions::MODULO) {
return $this->matchesModuloTraitValue($traitValue);
} else {
settype($castedValue, $traitValueType);
}
dump($castedValue); // 0
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels