Skip to content

Commit

Permalink
Merge pull request #209 from splitio/fix/iv_empty_str
Browse files Browse the repository at this point in the history
fix input validation for empty keys
  • Loading branch information
mredolatti authored Jul 24, 2023
2 parents cd9133b + 524b743 commit 8b3753a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @splitio/sdk
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
7.1.8 (Jul 24, 2023)
- Fixed input validation for empty keys.

7.1.7 (May 16, 2023)
- Updated terminology on the SDKs codebase to be more aligned with current standard without causing a breaking change. The core change is the term split for feature flag on things like logs and phpdoc comments.
- Fixed php 8.2 warnings in code.
Expand Down
4 changes: 2 additions & 2 deletions src/SplitIO/Sdk/Validator/InputValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private static function checkIsNull($value, $name, $nameType, $operation)
private static function checkIsEmpty($value, $name, $nameType, $operation)
{
$trimmed = trim($value);
if (empty($trimmed)) {
if (0 == strlen($trimmed)) {
SplitApp::logger()->critical($operation . ": you passed an empty " . $name . ", " . $nameType .
" must be a non-empty string.");
return true;
Expand Down Expand Up @@ -265,7 +265,7 @@ function ($featureFlagName) use ($operation) {
)
)
);
if (empty($filteredArray)) {
if (0 == count($filteredArray)) {
SplitApp::logger()->critical($operation . ': featureFlagNames must be a non-empty array.');
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SplitIO/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class Version
{
const CURRENT = '7.1.7';
const CURRENT = '7.1.8';
}
1 change: 1 addition & 0 deletions tests/Suite/InputValidation/GetTreatmentValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public function testGetTreatmentWithEmptyMatchingKeyObject()
$splitSdk = $this->getFactoryClient();

$this->assertEquals('control', $splitSdk->getTreatment(new Key('', 'some_bucketing_key'), 'some_feature'));
$this->assertNotEquals('control', $splitSdk->getTreatment(new Key("0", 'some_bucketing_key'), 'some_feature'));
}

public function testGetTreatmentWithWrongTypeMatchingKeyObject()
Expand Down

0 comments on commit 8b3753a

Please sign in to comment.