Skip to content

Commit

Permalink
OXDEV-8840 Fix ajax error message when using http2
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaIvanovski committed Oct 23, 2024
1 parent a668709 commit 6054a53
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assets/out/src/js/base.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/out/src/js/base.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/base/medialibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
ui._loadItemDetails(activeItem.data(), $dialog);
},
error: function (result, status, errorThrown) {
ddh.alert(ddh.translate(errorThrown));
ddh.alert(ddh.translate(result.responseJSON.error));
}
});
}
Expand Down
5 changes: 5 additions & 0 deletions src/Validation/Validator/FileNameValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public function checkFilenameNotEmpty(string $fileName): void
if (!$fileName) {
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_EMPTY");
}

$fileName = str_replace(' ', '', $fileName);
if (strlen($fileName) < 1) {
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_EMPTY");
}
}

public function checkFilenameDoesNotStartWithDot(string $fileName): void
Expand Down
24 changes: 14 additions & 10 deletions tests/Unit/Validation/Validator/FileNameValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,18 @@
#[CoversClass(FileNameValidator::class)]
class FileNameValidatorTest extends TestCase
{
public function testRegularFileNameDoesntThrowExceptions(): void
public static function goodFileNamesDataProvider(): \Generator
{
yield "regular file name" => [
'fileName' => uniqid(),
];
}

#[DataProvider('goodFileNamesDataProvider')]
public function testRegularFileNameDoesntThrowExceptions(string $fileName): void
{
$filePathStub = $this->createConfiguredStub(FilePath::class, [
'getFileName' => uniqid()
'getFileName' => $fileName
]);

$sut = new FileNameValidator();
Expand All @@ -31,20 +39,16 @@ public function testRegularFileNameDoesntThrowExceptions(): void
$this->addToAssertionCount(1);
}

public static function goodFileNamesDataProvider(): \Generator
{
yield "regular file name" => [
'baseName' => uniqid(),
'extension' => uniqid()
];
}

public static function badFileNamesDataProvider(): \Generator
{
yield "empty" => [
'fileName' => ''
];

yield "empty with spaces" => [
'fileName' => ' '
];

yield "starts with dot" => [
'fileName' => '.' . uniqid()
];
Expand Down

0 comments on commit 6054a53

Please sign in to comment.