diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-27 20:38:23 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-27 20:38:23 +0300 |
| commit | ac7b51679ca4df5fbb70d0ac796935de191b5e0d (patch) | |
| tree | 57edeb202b8308a51927a76d50f1ae558d890d69 /tests | |
| parent | bac87949cb64ce8fffb4cd2d4e7440e943c7b314 (diff) | |
| download | the-epube-ac7b51679ca4df5fbb70d0ac796935de191b5e0d.tar.gz the-epube-ac7b51679ca4df5fbb70d0ac796935de191b5e0d.tar.xz | |
for log timestamp test, treat PID as optional; add idn tests
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/DebugTest.php | 4 | ||||
| -rw-r--r-- | tests/SanitizerTest.php | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/tests/DebugTest.php b/tests/DebugTest.php index 8156035..3c4653c 100644 --- a/tests/DebugTest.php +++ b/tests/DebugTest.php @@ -141,8 +141,8 @@ final class DebugTest extends TestCase Debug::log('timestamp test', Debug::LOG_NORMAL); $content = file_get_contents($this->tmpLogfile); - // Format: [HH:MM:SS/PID] message - $this->assertMatchesRegularExpression('/\[\d{2}:\d{2}:\d{2}\/\d+\]/', $content); + // Format: [HH:MM:SS/PID] message, PID is optional + $this->assertMatchesRegularExpression('/\[\d{2}:\d{2}:\d{2}(\/\d+)?\]/', $content); } public function test_log_multiple_messages_to_file(): void diff --git a/tests/SanitizerTest.php b/tests/SanitizerTest.php index 2560970..27a99bd 100644 --- a/tests/SanitizerTest.php +++ b/tests/SanitizerTest.php @@ -236,6 +236,12 @@ final class SanitizerTest extends TestCase { $this->assertEquals('<p>hello</p>', $result); } + public function test_sanitize_strips_body_wrapper(): void { + $input = '<html><body><p>content</p></body></html>'; + $result = Sanitizer::sanitize($input); + $this->assertEquals('<p>content</p>', $result); + } + // --------------------------------------------------------------------------- // Sanitizer::rewrite_relative() // --------------------------------------------------------------------------- @@ -421,11 +427,21 @@ final class SanitizerTest extends TestCase { $this->assertFalse($result); } + public function test_validate_idn_to_ascii(): void { + $result = Sanitizer::validate('http://пример.com/path'); + $this->assertEquals('http://xn--e1afmkfd.com/path', $result); + } + public function test_validate_url_with_encoded_path(): void { $result = Sanitizer::validate('http://example.com/path%20with%20spaces'); $this->assertNotFalse($result); } + public function test_validate_idn_to_ascii_chinese(): void { + $result = Sanitizer::validate('http://例子.测试/path'); + $this->assertStringContainsString('xn--', $result); + } + public function test_validate_strips_whitespace(): void { $result = Sanitizer::validate(' http://example.com/path '); $this->assertEquals('http://example.com/path', $result); |
