Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/Service/FormsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
*/
class FormsService {
private ?IUser $currentUser;

public function __construct(
IUserSession $userSession,
private ActivityManager $activityManager,
Expand Down Expand Up @@ -780,6 +780,6 @@ public function getTemporaryUploadedFilePath(Form $form, Question $question): st
}

private static function normalizeFileName(string $fileName): string {
return str_replace(mb_str_split(\OCP\Constants::FILENAME_INVALID_CHARS), '-', $fileName);
return str_replace([...mb_str_split(\OCP\Constants::FILENAME_INVALID_CHARS), "\n"], '-', $fileName);
}
}
7 changes: 7 additions & 0 deletions tests/Unit/Service/FormsServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1445,6 +1445,13 @@ public function testGetFileNameThrowsAnExceptionForInvalidFormat() {
$this->formsService->getFileName($form, 'dummy');
}

public function testGetFileNameReplacesNewLines() {
$form = new Form();
$form->setTitle("Form \n new line");

$this->assertSame('Form - new line (responses).xlsx', $this->formsService->getFileName($form, 'xlsx'));
}

public function testGetFileName() {
$form = new Form();
$form->setTitle('Form 1');
Expand Down