-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve urlencoded data in the rewritten path
- Loading branch information
Showing
4 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/playground/data-liberation/tests/UrldecodeNTests.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
class UrldecodeNTests extends TestCase { | ||
|
||
/** | ||
* | ||
* @dataProvider provider_test_urldecode_n | ||
*/ | ||
public function test_urldecode_n( | ||
$original_string, | ||
$decode_length, | ||
$expected_string, | ||
) { | ||
$result = urldecode_n( $original_string, $decode_length ); | ||
$this->assertEquals( $expected_string, $result, 'Failed to decode the first n bytes of the string' ); | ||
} | ||
|
||
static public function provider_test_urldecode_n() { | ||
return [ | ||
'Encoded path segment with no encoded bytes later on' => [ | ||
'original_string' => '/%73/%63/image.png', | ||
'decode_length' => 4, | ||
'expected_string' => '/s/c/image.png', | ||
], | ||
'Encoded path segment with encoded bytes later on' => [ | ||
'original_string' => '/%73/%63/%73%63ience.png', | ||
'decode_length' => 4, | ||
'expected_string' => '/s/c/%73%63ience.png', | ||
], | ||
'Decode past the encoded path segment' => [ | ||
'original_string' => '/%73/%63/science.png', | ||
'decode_length' => 10, | ||
'expected_string' => '/s/c/science.png', | ||
], | ||
'Double percent sign – decode it' => [ | ||
'original_string' => '/%%73cience.png', | ||
'decode_length' => 3, | ||
'expected_string' => '/%science.png', | ||
], | ||
'Double percent sign – finish decoding after the first percent sign' => [ | ||
'original_string' => '/%%73cience.png', | ||
'decode_length' => 2, | ||
'expected_string' => '/%%73cience.png', | ||
], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters