Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/PhpInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ public function doNotSanitizeSessionId(): self
}


/**
* @param non-empty-string $sanitize
*/
public function addSanitization(string $sanitize, ?string $with = null): self
{
$this->sanitizer->addSanitization($sanitize, $with);
Expand Down
6 changes: 3 additions & 3 deletions src/SensitiveValueSanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public function doNotSanitizeSessionId(): self
}


/**
* @param non-empty-string $sanitize
*/
public function addSanitization(string $sanitize, ?string $with = null): self
{
if ($sanitize === '') {
return $this;
}
$this->sanitize[$sanitize] = $this->sanitize[urlencode($sanitize)] = $with ?? $this->sanitizeWith;
return $this;
}
Expand Down
10 changes: 10 additions & 0 deletions tests/SensitiveValueSanitizerTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ class SensitiveValueSanitizerTest extends TestCase
Assert::notContains($sessionId, $html);
}


public function testAddSanitizationEmptyString(): void
{
Assert::noError(function () use (&$string): void {
$string = (new SensitiveValueSanitizer())->addSanitization('', '💫')->sanitize('foo');
});
Assert::same('foo', $string);
Assert::notContains('💫', $string);
}

}

(new SensitiveValueSanitizerTest())->run();