Download tasks/0f14f6d6f735175e/levels/level3/patch.diff from FuCY/php: direct link, hf CLI and curl.
- Browser
- Download file 2.25 kB
-
https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/0f14f6d6f735175e/levels/level3/patch.diff
- Command line
-
hf download hf://datasets/FuCY/php/tasks/0f14f6d6f735175e/levels/level3/patch.diff
-
curl -L -o patch.diff https://huggingface.co/datasets/FuCY/php/resolve/main/tasks/0f14f6d6f735175e/levels/level3/patch.diff
2.25 kB
| diff --git a/src/Knp/Snappy/AbstractGenerator.php b/src/Knp/Snappy/AbstractGenerator.php | |
| index 643376f2..1189e95a 100644 | |
| --- a/src/Knp/Snappy/AbstractGenerator.php | |
| +++ b/src/Knp/Snappy/AbstractGenerator.php | |
| protected function executeCommand($command) | |
| */ | |
| protected function prepareOutput($filename, $overwrite) | |
| { | |
| - if (\strpos($filename, 'phar://') === 0) { | |
| - throw new InvalidArgumentException('The output file cannot be a phar archive.'); | |
| + if (false === $parsedFilename = \parse_url($filename)) { | |
| + throw new InvalidArgumentException('The output filename is invalid.'); | |
| + } | |
| + | |
| + $scheme = isset($parsedFilename['scheme']) ? \mb_strtolower($parsedFilename['scheme']) : ''; | |
| + if ($scheme !== '' && $scheme !== 'file') { | |
| + throw new InvalidArgumentException(\sprintf('The output file scheme is not supported. Expected \'\' or \'file\' but got \'%s\'.', $scheme)); | |
| } | |
| $directory = \dirname($filename); | |
| diff --git a/tests/Knp/Snappy/AbstractGeneratorTest.php b/tests/Knp/Snappy/AbstractGeneratorTest.php | |
| index 1ab6a900..da5136a8 100644 | |
| --- a/tests/Knp/Snappy/AbstractGeneratorTest.php | |
| +++ b/tests/Knp/Snappy/AbstractGeneratorTest.php | |
| public function testFailingGenerateWithOutputContainingPharPrefix(): void | |
| $media->generate('the_input_file', 'phar://the_output_file', ['foo' => 'bar']); | |
| } | |
| + public function testFailingGenerateWithOutputContainingUppercasePharPrefix(): void | |
| + { | |
| + $media = $this->getMockBuilder(AbstractGenerator::class) | |
| + ->setMethods([ | |
| + 'configure', | |
| + 'prepareOutput', | |
| + ]) | |
| + ->setConstructorArgs(['the_binary', [], ['PATH' => '/usr/bin']]) | |
| + ->getMock() | |
| + ; | |
| + | |
| + $media->setTimeout(2000); | |
| + | |
| + $media | |
| + ->expects($this->once()) | |
| + ->method('prepareOutput') | |
| + ->with($this->equalTo('PHAR://the_output_file')) | |
| + ; | |
| + | |
| + $this->expectException(InvalidArgumentException::class); | |
| + | |
| + $media->generate('the_input_file', 'PHAR://the_output_file', ['foo' => 'bar']); | |
| + } | |
| + | |
| /** | |
| * @return null|string | |
| */ | |