Skip to content

Commit

Permalink
Additional PHP8.1 hardening
Browse files Browse the repository at this point in the history
Uses the same logic as already included in EncryptedText
  • Loading branch information
scott-nz committed Oct 27, 2023
1 parent 0c1240a commit e148e60
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/FieldType/EncryptedDatetime.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function setValue($value, $record = null, $markChanged = true)

public function getDecryptedValue($value)
{
// Type hardening for PHP 8.1+
$value = (string)$value;
// Test if we're actually an encrypted value;
if (ctype_xdigit($value) && strlen($value) > 130) {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/FieldType/EncryptedDecimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function setValue($value, $record = null, $markChanged = true)

public function getDecryptedValue($value)
{
// Type hardening for PHP 8.1+
$value = (string)$value;
// Test if we're actually an encrypted value;
if (ctype_xdigit($value) && strlen($value) > 130) {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/FieldType/EncryptedEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public function setValue($value, $record = null, $markChanged = true)

public function getDecryptedValue($value)
{
// Type hardening for PHP 8.1+
$value = (string)$value;
// Test if we're actually an encrypted value;
if (ctype_xdigit($value) && strlen($value) > 130) {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/FieldType/EncryptedInt.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function setValue($value, $record = null, $markChanged = true)

public function getDecryptedValue($value)
{
// Type hardening for PHP 8.1+
$value = (string)$value;
// Test if we're actually an encrypted value;
if (ctype_xdigit($value) && strlen($value) > 130) {
try {
Expand Down
2 changes: 2 additions & 0 deletions src/FieldType/EncryptedVarchar.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public function setValue($value, $record = null, $markChanged = true)

public function getDecryptedValue($value)
{
// Type hardening for PHP 8.1+
$value = (string)$value;
// Test if we're actually an encrypted value;
if (ctype_xdigit($value) && strlen($value) > 130) {
try {
Expand Down

0 comments on commit e148e60

Please sign in to comment.