cryptic-game/frontend

Invalid Path with space at end possible

Tristan-H11 opened this issue · 4 comments

Describe the bug
You can create folders ending with a space. This leads to a not catched error "invalid path", which is not shown to the user.

Reproduce
Create a new folder with the name "new-folder "

Logs
The blue marked text is the space.
grafik

I am just looking at the problem and I found the place (file-manager.component.ts#createDirectory()). It looks like there is already a suitable exception handling. The check would need to be adjusted (also/for the best solution) in the backend.
This would have to throw the exception via the websocket.

newFolder(name: string) {
    this.fileService.createDirectory(this.delegate.device.uuid, name, this.currentFolder.uuid).subscribe({
      error: (e: Error) => {
        [...]
        if (e.message === 'invalid_input_data') {
          this.displayError('The specified folder name is not valid.');
        } 
        [...]
      }
    });
  }

@TimJ0212 Very nice! Already figured out, that the backend needs to update their validations here. I'm going to create an issue later on.