fix: cap Base64 media transfers at 10 MB, upload limit at most 32 MB
This commit is contained in:
@@ -131,6 +131,18 @@ final class MediaImporterTest extends TestCase
|
||||
self::assertSame([], $this->tempFiles, 'no temp file may be written for an oversized upload');
|
||||
}
|
||||
|
||||
public function testBase64UploadsAreCappedAtTenMegabytesEvenWithAHigherUploadLimit(): void
|
||||
{
|
||||
Functions\when('get_option')->justReturn(['upload_mb' => 32]);
|
||||
|
||||
$result = $this->importer()->fromBase64(str_repeat('A', 16 * 1024 * 1024), 'big.png', []);
|
||||
|
||||
self::assertSame('lit_validation_failed', $result->get_error_code());
|
||||
self::assertStringContainsString('Limit 10 MB', $result->get_error_message());
|
||||
self::assertStringContainsString('lit/media-upload-from-url', (string) $result->get_error_data()['hint']);
|
||||
self::assertSame([], $this->tempFiles);
|
||||
}
|
||||
|
||||
public function testInvalidBase64IsRejected(): void
|
||||
{
|
||||
$result = $this->importer()->fromBase64('***', 'x.png', []);
|
||||
|
||||
Reference in New Issue
Block a user