Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.
TypeScript cloud-alternativecollaborationcollaborative-editingdropboxfile-serverfile-sharingfile-storagefile-syncfull-text-searchhomelabnextcloudon-premiseopen-sourceprivacy-firstprivate-cloudrealtimesecureself-hostedstorage-serverwebdav
fix(spaces,shares,files): harden names, aliases and paths
johaven6d6969aafe73
diff --git a/backend/src/applications/files/utils/files.spec.ts b/backend/src/applications/files/utils/files.spec.tsindex f35be6b9..865de371 100644--- a/backend/src/applications/files/utils/files.spec.ts+++ b/backend/src/applications/files/utils/files.spec.ts@@ -7,7 +7,7 @@ import fse from 'fs-extra'import type { MockInstance } from 'vitest'import { FileError } from '../models/file-error'import { storageQuotaExceededError } from './errors'-import { createSizeLimiter, isCrossDevice, isPathInside, makeTempDir, tempFilePath, writeFromStream } from './files'+import { createSizeLimiter, isCrossDevice, isPathInside, makeTempDir, sanitizeName, tempFilePath, writeFromStream } from './files'import { FILE_ERROR } from '../constants/errors'describe(createSizeLimiter.name, () => {@@ -43,6 +43,15 @@ describe(isPathInside.name, () => {})})+describe(sanitizeName.name, () => {+ it('removes separators before stripping trailing path segments', () => {+ expect(sanitizeName('./')).toBe('')+ expect(sanitizeName('.\\')).toBe('')+ expect(sanitizeName('folder./')).toBe('folder')+ expect(sanitizeName('archive.tar.gz')).toBe('archive.tar.gz')+ })+})+describe(isCrossDevice.name, () => {afterEach(() => {vi.restoreAllMocks()diff --git a/backend/src/applications/files/utils/files.ts b/backend/src/applications/files/utils/files.tsindex 75f7b376..0c9714fc 100644--- a/backend/src/applications/files/utils/files.ts+++ b/backend/src/applications/files/utils/files.ts@@ -33,9 +33,9 @@ export function isPathInside(basePath: string, candidatePath: string, allowBasePexport function sanitizeName(name: string): string {return name- .replace(/^\s+|[. ]+$/g, '') // trimStart + trimEnd + strip trailing dots.replace(/[/\\]/g, '') // remove slashes.replace(/\.\./g, '') // remove '..'+ .replace(/^\s+|[. ]+$/g, '') // trimStart + trimEnd + strip trailing dots}export function checkFileName(fPath: string): string {diff --git a/backend/src/applications/shares/services/shares-manager.service.spec.ts b/backend/src/applications/shares/services/shares-manager.service.spec.tsindex 3b98bfc4..c2c15b93 100644--- a/backend/src/applications/shares/services/shares-manager.service.spec.ts+++ b/backend/src/applications/shares/services/shares-manager.service.spec.ts@@ -96,6 +96,7 @@ describe(SharesManager.name, () => {updateMembers: vi.fn(),shareExistsForOwner: vi.fn(),childExistsForShareOwner: vi.fn(),+ uniqueShareAlias: vi.fn(),clearCacheIdentities: vi.fn().mockResolvedValue(true),clearCachePermissions: vi.fn().mockResolvedValue(true)}@@ -561,4 +562,16 @@ describe(SharesManager.name, () => {expect(linksQueriesMock.isUniqueUUID).toHaveBeenCalledWith(user.id, 'only-one')})})++ describe('alias generation', () => {+ const currentShareId = 42+ const uniqueShareAlias = (name: string): Promise<string> => (service as any).uniqueShareAlias(name, currentShareId)++ it('should exclude the current share when checking its alias', async () => {+ sharesQueriesMock.uniqueShareAlias.mockResolvedValueOnce('leba-est-chez-moi')++ await expect(uniqueShareAlias('Lébà est chez moi')).resolves.toBe('leba-est-chez-moi')+ expect(sharesQueriesMock.uniqueShareAlias).toHaveBeenCalledWith('Lébà est chez moi', currentShareId)+ })+ })})diff --git a/backend/src/applications/shares/services/shares-manager.service.ts b/backend/src/applications/shares/services/shares-manager.service.tsindex e453c157..bbd84102 100644--- a/backend/src/applications/shares/services/shares-manager.service.ts+++ b/backend/src/applications/shares/services/shares-manager.service.ts@@ -10,7 +10,7 @@ import {hashPassword} from '../../../common/functions'import type { Entries } from '../../../common/interfaces'-import { intersectPermissions } from '../../../common/shared'+import { intersectPermissions, InvalidSlugError } from '../../../common/shared'import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'import type { FileProps } from '../../files/interfaces/file-props.interface'import { FileError } from '../../files/models/file-error'@@ -128,7 +128,7 @@ export class SharesManager {async createShare(user: UserModel, createOrUpdateShareDto: CreateOrUpdateShareDto): Promise<ShareProps> {const share: Partial<Share> = {name: createOrUpdateShareDto.name,- alias: await this.sharesQueries.uniqueShareAlias(createOrUpdateShareDto.name),+ alias: await this.uniqueShareAlias(createOrUpdateShareDto.name),description: createOrUpdateShareDto.description,externalPath: createOrUpdateShareDto.externalPath,enabled: createOrUpdateShareDto.enabled,@@ -242,7 +242,7 @@ export class SharesManager {shareDiffProps[prop] = createOrUpdateShareDto[prop]if (prop === 'name') {renamedShareAlias = share.alias- shareDiffProps.alias = await this.sharesQueries.uniqueShareAlias(shareDiffProps.name)+ shareDiffProps.alias = await this.uniqueShareAlias(shareDiffProps.name, shareId)} else if (prop === 'enabled') {shareDiffProps.disabledAt = shareDiffProps[prop] ? null : new Date()}@@ -387,7 +387,7 @@ export class SharesManager {const share: Partial<Share> = {name: createOrUpdateShareDto.name,- alias: await this.sharesQueries.uniqueShareAlias(createOrUpdateShareDto.name),+ alias: await this.uniqueShareAlias(createOrUpdateShareDto.name),ownerId: user.id,spaceId: pShareEnv.spaceId,spaceRootId: pShareEnv.spaceRootId,@@ -667,7 +667,7 @@ export class SharesManager {breakcase 'shareName':updateShare.name = v- updateShare.alias = await this.sharesQueries.uniqueShareAlias(v)+ updateShare.alias = await this.uniqueShareAlias(v, spaceOrShareId)breakcase 'shareDescription':updateShare.description = v@@ -750,6 +750,17 @@ export class SharesManager {await this.deleteGuestLinks(members)}+ private async uniqueShareAlias(name: string, excludedShareId?: number): Promise<string> {+ try {+ return await this.sharesQueries.uniqueShareAlias(name, excludedShareId)+ } catch (e) {+ if (e instanceof InvalidSlugError) {+ throw new HttpException(e.message, HttpStatus.BAD_REQUEST)+ }+ throw e+ }+ }+private async updateMembers(user: UserModel, share: Partial<Share>, oldMembers: ShareMemberDto[], currentMembers: ShareMemberDto[]) {if (oldMembers.length === 0 && currentMembers.length === 0) {returndiff --git a/backend/src/applications/shares/services/shares-queries.service.ts b/backend/src/applications/shares/services/shares-queries.service.tsindex 5d68c26b..9fe601ad 100644--- a/backend/src/applications/shares/services/shares-queries.service.ts+++ b/backend/src/applications/shares/services/shares-queries.service.ts@@ -63,13 +63,13 @@ export class SharesQueries {public readonly cache: Cache) {}- async uniqueShareAlias(name: string): Promise<string> {- let alias = createSlug(name, true)+ async uniqueShareAlias(name: string, excludedShareId?: number): Promise<string> {+ const originalAlias = createSlug(name, true)+ let alias = originalAliaslet count = 0- // Personal space name is reserved- while (await this.shareExistsForAlias(alias)) {+ while (await this.shareExistsForAlias(alias, excludedShareId)) {count += 1- alias = `${name}-${count}`+ alias = `${originalAlias}-${count}`}return alias}@@ -923,8 +923,11 @@ export class SharesQueries {}}- private shareExistsForAlias(alias: string): any | undefined {- return this.db.query.shares.findFirst({ columns: { id: true }, where: eq(shares.alias, alias) })+ private shareExistsForAlias(alias: string, excludedShareId?: number): any | undefined {+ return this.db.query.shares.findFirst({+ columns: { id: true },+ where: excludedShareId === undefined ? eq(shares.alias, alias) : and(eq(shares.alias, alias), ne(shares.id, excludedShareId))+ })}private fromUserQuery(select: SelectedFields<any, any>, filters: SQL[] = []) {diff --git a/backend/src/applications/spaces/models/space.model.ts b/backend/src/applications/spaces/models/space.model.tsindex 55a85085..784103cf 100644--- a/backend/src/applications/spaces/models/space.model.ts+++ b/backend/src/applications/spaces/models/space.model.ts@@ -1,6 +1,7 @@import fs from 'node:fs/promises'import path from 'node:path'import { configuration } from '../../../configuration/config.environment'+import { isPathInside } from '../../files/utils/files'import { SPACE_REPOSITORY } from '../constants/spaces'import { SpaceRoot } from '../schemas/space-root.interface'import { Space } from '../schemas/space.interface'@@ -20,26 +21,11 @@ export class SpaceModel implements Space {// outside db schemaroot: SpaceRoot[] = []- private _homePath: string- private _filesPath: string- private _trashPath: stringconstructor(props: any) {Object.assign(this, props)}- get homePath(): string {- return (this._homePath ||= path.join(configuration.applications.files.spacesPath, this.alias))- }-- get filesPath(): string {- return (this._filesPath ||= path.join(this.homePath, SPACE_REPOSITORY.FILES))- }-- get trashPath(): string {- return (this._trashPath ||= path.join(this.homePath, SPACE_REPOSITORY.TRASH))- }-static async makePaths(spaceAlias: string) {for (const p of [SpaceModel.getFilesPath(spaceAlias), SpaceModel.getTrashPath(spaceAlias)]) {await fs.mkdir(p, { recursive: true })@@ -47,7 +33,14 @@ export class SpaceModel implements Space {}static getHomePath(spaceAlias: string) {- return path.join(configuration.applications.files.spacesPath, spaceAlias)+ const spacesPath = path.resolve(configuration.applications.files.spacesPath)+ const homePath = path.resolve(spacesPath, spaceAlias)++ if (!isPathInside(spacesPath, homePath)) {+ throw new Error(`Invalid space home path for alias: ${spaceAlias}`)+ }++ return homePath}static getFilesPath(spaceAlias: string) {diff --git a/backend/src/applications/spaces/services/spaces-browser.service.ts b/backend/src/applications/spaces/services/spaces-browser.service.tsindex d7105edd..4dda77ef 100644--- a/backend/src/applications/spaces/services/spaces-browser.service.ts+++ b/backend/src/applications/spaces/services/spaces-browser.service.ts@@ -291,7 +291,8 @@ export class SpacesBrowser {space.id,f.root.alias,fsFiles.map((f) => f.name),- true+ true,+ f.root.id)if (newAlias) {this.logger.log({ tag: this.mergeSpaceRootFiles.name, msg: `update space root alias (${f.root.id}) : ${f.root.alias} -> ${newAlias}` })diff --git a/backend/src/applications/spaces/services/spaces-manager.service.spec.ts b/backend/src/applications/spaces/services/spaces-manager.service.spec.tsindex daa6622a..79abbc77 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.spec.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.spec.ts@@ -222,4 +222,28 @@ describe(SpacesManager.name, () => {await expect(spacesManager.listSpaceShares(userTest, 10)).rejects.toEqual(new HttpException('Unauthorized', HttpStatus.FORBIDDEN))})++ describe('alias generation', () => {+ const currentSpaceId = 42+ const currentRootId = 24+ const name = 'Lébà est chez moi'+ const alias = 'leba-est-chez-moi'+ const uniqueSpaceAlias = (value: string): Promise<string> => (spacesManager as any).uniqueSpaceAlias(value, true, currentSpaceId)++ it('should preserve the current space alias when the renamed name produces the same slug', async () => {+ const spaceExistsSpy = vi.spyOn(spacesQueries, 'spaceExistsForAlias').mockResolvedValueOnce(undefined)++ await expect(uniqueSpaceAlias(name)).resolves.toBe(alias)+ expect(spaceExistsSpy).toHaveBeenCalledWith(alias, currentSpaceId)+ spaceExistsSpy.mockRestore()+ })++ it('should exclude the current root when checking its alias', async () => {+ const rootExistsSpy = vi.spyOn(spacesQueries, 'spaceRootExistsForAlias').mockResolvedValueOnce(undefined)++ await expect(spacesManager.uniqueRootAlias(1, alias, [], true, currentRootId)).resolves.toBeNull()+ expect(rootExistsSpy).toHaveBeenCalledWith(1, alias, currentRootId)+ rootExistsSpy.mockRestore()+ })+ })})diff --git a/backend/src/applications/spaces/services/spaces-manager.service.ts b/backend/src/applications/spaces/services/spaces-manager.service.tsindex cd76c2dd..e44e7905 100644--- a/backend/src/applications/spaces/services/spaces-manager.service.ts+++ b/backend/src/applications/spaces/services/spaces-manager.service.ts@@ -5,7 +5,7 @@ import path from 'node:path'import { ACTION } from '../../../common/constants'import { convertDiffUpdate, diffCollection, differencePermissions } from '../../../common/functions'import type { Entries } from '../../../common/interfaces'-import { createSlug, regExpNumberSuffix } from '../../../common/shared'+import { createSlug, InvalidSlugError, regExpNumberSuffix } from '../../../common/shared'import { configuration } from '../../../configuration/config.environment'import { ContextManager } from '../../../infrastructure/context/services/context-manager.service'import { FileError } from '../../files/models/file-error'@@ -245,7 +245,7 @@ export class SpacesManager {spaceDiffProps[prop] = createOrUpdateSpaceDto[prop]if (prop === 'name') {renamedSpaceAlias = space.alias- spaceDiffProps.alias = await this.uniqueSpaceAlias(spaceDiffProps.name, true)+ spaceDiffProps.alias = await this.uniqueSpaceAlias(spaceDiffProps.name, true, space.id)if (space.alias !== spaceDiffProps.alias) {// must move the space to match the new aliasconst spaceLocationWasRenamed: boolean = await this.renameSpaceLocation(space.alias, spaceDiffProps.alias)@@ -360,16 +360,20 @@ export class SpacesManager {}}- async uniqueRootAlias(spaceId: number, alias: string, aliasesAndNames: string[], replaceCount = false): Promise<string> {+ async uniqueRootAlias(spaceId: number, alias: string, aliasesAndNames: string[], replaceCount = false, excludedRootId?: number): Promise<string> {/* for some webdav clients the root alias is displayed instead of the file name.* This is why a root alias must be unique for files too */- if (aliasesAndNames.find((fName: string) => alias.toLowerCase() === fName.toLowerCase())) {+ const aliasExists = (candidate: string): boolean => {+ const normalizedCandidate = candidate.toLowerCase()+ return aliasesAndNames.some((aliasOrName: string) => normalizedCandidate === aliasOrName.toLowerCase())+ }+ if (aliasExists(alias) || (await this.spacesQueries.spaceRootExistsForAlias(spaceId, alias, excludedRootId))) {const aliasExtension = path.extname(alias)const aliasWithoutExtension = path.basename(alias, aliasExtension)- const originalAlias = createSlug(aliasWithoutExtension, replaceCount)+ const originalAlias = this.createAliasSlug(aliasWithoutExtension, replaceCount)let count = 1let newAlias = `${originalAlias}-${count}${aliasExtension}`- while (await this.spacesQueries.spaceRootExistsForAlias(spaceId, newAlias)) {+ while (aliasExists(newAlias) || (await this.spacesQueries.spaceRootExistsForAlias(spaceId, newAlias, excludedRootId))) {count += 1newAlias = `${originalAlias}-${count}${aliasExtension}`}@@ -557,19 +561,38 @@ export class SpacesManager {// updatefor (const props of toUpdate) {+ const root = props.object as SpaceRootPropsif ('alias' in props) {- props.alias.new = (await this.uniqueRootAlias(space.id, props.alias.new, aliases.concat(names), true)) || props.alias.new+ const aliasesAndNames = aliases.concat(names)+ const currentName = 'name' in props ? props.name.old : root.name+ for (const currentValue of [props.alias.old, currentName]) {+ const currentValueIndex = aliasesAndNames.findIndex((aliasOrName: string) => aliasOrName.toLowerCase() === currentValue.toLowerCase())+ if (currentValueIndex > -1) {+ aliasesAndNames.splice(currentValueIndex, 1)+ }+ }+ props.alias.new = (await this.uniqueRootAlias(space.id, props.alias.new, aliasesAndNames, true, root.id)) || props.alias.new// remove from space cache permissionsthis.spacesQueries.clearCachePermissions(space.alias, [props.alias.old, props.alias.new]).catch((e: Error) => this.logger.error({ tag: this.updateRoots.name, msg: `${e}` }))// update aliases list for next roots- aliases.push(props.alias.new)+ const currentAliasIndex = aliases.indexOf(props.alias.old)+ if (currentAliasIndex > -1) {+ aliases.splice(currentAliasIndex, 1, props.alias.new)+ } else {+ aliases.push(props.alias.new)+ }}if ('name' in props) {props.name.new = this.uniqueRootName(props.name.new, names) || props.name.new// update names list for next roots- names.push(props.name.new)+ const currentNameIndex = names.lastIndexOf(props.name.old)+ if (currentNameIndex > -1) {+ names.splice(currentNameIndex, 1, props.name.new)+ } else {+ names.push(props.name.new)+ }}}@@ -726,21 +749,33 @@ export class SpacesManager {}}- private async uniqueSpaceAlias(name: string, replaceCount = false): Promise<string> {- let alias = createSlug(name, replaceCount)+ private async uniqueSpaceAlias(name: string, replaceCount = false, excludedSpaceId?: number): Promise<string> {+ const originalAlias = this.createAliasSlug(name, replaceCount)+ let alias = originalAliaslet count = 0// Personal space name is reservedif (alias === SPACE_ALIAS.PERSONAL) {count += 1- alias = `${name}-${count}`+ alias = `${originalAlias}-${count}`}- while (await this.spacesQueries.spaceExistsForAlias(alias)) {+ while (await this.spacesQueries.spaceExistsForAlias(alias, excludedSpaceId)) {count += 1- alias = `${name}-${count}`+ alias = `${originalAlias}-${count}`}return alias}+ private createAliasSlug(name: string, replaceCount = false): string {+ try {+ return createSlug(name, replaceCount)+ } catch (e) {+ if (e instanceof InvalidSlugError) {+ throw new HttpException(e.message, HttpStatus.BAD_REQUEST)+ }+ throw e+ }+ }+private async userCanAccessSpace(user: UserModel, spaceId: number, asManager: true): Promise<SpaceProps>private async userCanAccessSpace(user: UserModel, spaceId: number, asManager?: false): Promise<Partial<SpaceProps>>private async userCanAccessSpace(user: UserModel, spaceId: number, asManager: boolean = false): Promise<Partial<SpaceProps>> {diff --git a/backend/src/applications/spaces/services/spaces-queries.service.ts b/backend/src/applications/spaces/services/spaces-queries.service.tsindex 326fb411..7c9d7d1e 100644--- a/backend/src/applications/spaces/services/spaces-queries.service.ts+++ b/backend/src/applications/spaces/services/spaces-queries.service.ts@@ -1,5 +1,5 @@import { Inject, Injectable, Logger } from '@nestjs/common'-import { and, countDistinct, eq, isNotNull, isNull, max, or, SelectedFields, SQL, sql } from 'drizzle-orm'+import { and, countDistinct, eq, isNotNull, isNull, max, ne, or, SelectedFields, SQL, sql } from 'drizzle-orm'import { alias, union } from 'drizzle-orm/mysql-core'import { MySql2PreparedQuery, MySqlQueryResult } from 'drizzle-orm/mysql2'import { ACTION } from '../../../common/constants'@@ -66,14 +66,20 @@ export class SpacesQueries {private readonly filesQueries: FilesQueries) {}- spaceExistsForAlias(alias: string): any | undefined {- return this.db.query.spaces.findFirst({ columns: { id: true }, where: eq(spaces.alias, alias) })+ spaceExistsForAlias(alias: string, excludedSpaceId?: number): any | undefined {+ return this.db.query.spaces.findFirst({+ columns: { id: true },+ where: excludedSpaceId === undefined ? eq(spaces.alias, alias) : and(eq(spaces.alias, alias), ne(spaces.id, excludedSpaceId))+ })}- spaceRootExistsForAlias(spaceId: number, rootAlias: string): any | undefined {+ spaceRootExistsForAlias(spaceId: number, rootAlias: string, excludedRootId?: number): any | undefined {return this.db.query.spacesRoots.findFirst({columns: { id: true },- where: and(eq(spacesRoots.spaceId, spaceId), eq(spacesRoots.alias, rootAlias))+ where:+ excludedRootId === undefined+ ? and(eq(spacesRoots.spaceId, spaceId), eq(spacesRoots.alias, rootAlias))+ : and(eq(spacesRoots.spaceId, spaceId), eq(spacesRoots.alias, rootAlias), ne(spacesRoots.id, excludedRootId))})}diff --git a/backend/src/common/shared.spec.ts b/backend/src/common/shared.spec.tsindex 7f33a0f2..20d84dca 100644--- a/backend/src/common/shared.spec.ts+++ b/backend/src/common/shared.spec.ts@@ -1,4 +1,31 @@-import { stripMatchingQuotes } from './shared'+import { createCacheKeySlug, createSlug, InvalidSlugError, stripMatchingQuotes } from './shared'++describe(createSlug.name, () => {+ it.each([+ ['Hello world', 'hello-world'],+ ['Hello_world', 'hello-world'],+ ['Hello.world', 'hello-world'],+ ['Hello/world', 'hello-world'],+ ['Hello\\world', 'hello-world'],+ ['Équipe 東京', 'equipe-東京']+ ])('should convert %s to %s', (value, expectedValue) => {+ expect(createSlug(value)).toBe(expectedValue)+ })++ it('should remove a numeric suffix when requested', () => {+ expect(createSlug('workspace-2', true)).toBe('workspace')+ })++ it.each(['', '.', '..', '---', '___'])('should reject an empty slug generated from %s', (value) => {+ expect(() => createSlug(value)).toThrow(InvalidSlugError)+ })+})++describe(createCacheKeySlug.name, () => {+ it('should preserve cache pattern metacharacters', () => {+ expect(createCacheKeySlug(['SpacesQueries', 'spaces', 1, '*'])).toBe('spacesqueries-spaces-1-*')+ })+})describe(stripMatchingQuotes.name, () => {it.each([diff --git a/backend/src/common/shared.ts b/backend/src/common/shared.tsindex 9ee37f7c..e9697810 100644--- a/backend/src/common/shared.ts+++ b/backend/src/common/shared.ts@@ -17,6 +17,13 @@ export const regExpPreventPathTraversal = /^(\.\.(\/|\\|$))+/export const regExpNumberSuffix = /-\d+$/export const forbiddenChars = '\\ / : * ? " < > |'+export class InvalidSlugError extends Error {+ constructor() {+ super('Name must contain at least one letter or number')+ this.name = InvalidSlugError.name+ }+}+export function isValidFileName(fileName: string) {if (regExpInvalidFileName.test(fileName)) {throw new Error('Forbidden characters')@@ -32,19 +39,24 @@ export function currentDate(value?: string): Date {}export function createSlug(input: string, replaceCount = false): string {- const r = input- .toLowerCase()- .trim()- .replace(/[\s_-]+/g, '-')- .replace(/^-+|-+$/g, '')- .normalize('NFD')- .replace(/[\u0300-\u036f]/g, '')- if (replaceCount) return r.replace(regExpNumberSuffix, '')- return r+ let slug = createLightSlug(input)+ .replace(/[^\p{L}\p{N}]+/gu, '-')+ .replace(/^-|-$/g, '')++ if (replaceCount) {+ slug = slug.replace(regExpNumberSuffix, '')+ }+ if (!slug) {+ throw new InvalidSlugError()+ }+ return slug}export function createCacheKeySlug(args: unknown[]) {- return createSlug(args.map((arg) => (arg == null ? 'null' : String(arg))).join(' '))+ // Cache patterns intentionally preserve metacharacters such as `*`.+ return createLightSlug(args.map((arg) => (arg == null ? 'null' : String(arg))).join(' '))+ .replace(/[\s_-]+/g, '-')+ .replace(/^-+|-+$/g, '')}export function createLightSlug(input: string) {diff --git a/frontend/src/app/applications/spaces/components/utils/space-manage-roots.component.ts b/frontend/src/app/applications/spaces/components/utils/space-manage-roots.component.tsindex 4d46781a..cf3224fc 100644--- a/frontend/src/app/applications/spaces/components/utils/space-manage-roots.component.ts+++ b/frontend/src/app/applications/spaces/components/utils/space-manage-roots.component.ts@@ -3,7 +3,7 @@ import { Component, ElementRef, inject, Input, OnDestroy, OnInit, ViewChild } frimport { FormsModule } from '@angular/forms'import { FaIconComponent } from '@fortawesome/angular-fontawesome'import { faPen, faTimes } from '@fortawesome/free-solid-svg-icons'-import { createSlug, regExpNumberSuffix } from '@sync-in-server/backend/src/common/shared'+import { createSlug, InvalidSlugError, regExpNumberSuffix } from '@sync-in-server/backend/src/common/shared'import { L10N_LOCALE, L10nLocale, L10nTranslatePipe } from 'angular-l10n'import { ButtonsModule } from 'ngx-bootstrap/buttons'import { TooltipModule } from 'ngx-bootstrap/tooltip'@@ -12,6 +12,7 @@ import { InputEditDirective } from '../../../../common/directives/input-edit.dirimport { PathSlice } from '../../../../common/pipes/path-slice'import { TimeAgoPipe } from '../../../../common/pipes/time-ago.pipe'import { originalOrderKeyValue, uniqueNameFromCollection } from '../../../../common/utils/functions'+import { LayoutService } from '../../../../layout/layout.service'import { FileTreeEvent } from '../../../files/components/dialogs/files-tree-dialog.component'import { UserAvatarComponent } from '../../../users/components/utils/user-avatar.component'import { OwnerType } from '../../../users/interfaces/owner.interface'@@ -48,6 +49,7 @@ export class SpaceManageRootsComponent implements OnInit, OnDestroy {protected readonly icons = { faTimes, faPen }protected readonly SPACES_PERMISSIONS_TEXT = SPACES_PERMISSIONS_TEXTprotected readonly originalOrderKeyValue = originalOrderKeyValue+ private readonly layout = inject(LayoutService)private subscription: Subscription = nullngOnInit() {@@ -90,8 +92,18 @@ export class SpaceManageRootsComponent implements OnInit, OnDestroy {onRenameRoot(ev: { object: SpaceRootModel; name: string }): void {const spaceRoot: SpaceRootModel = ev.object+ let alias: string+ try {+ alias = createSlug(ev.name, true)+ } catch (e) {+ if (e instanceof InvalidSlugError) {+ this.layout.sendNotification('error', 'Invalid name', e.message)+ return+ }+ throw e+ }spaceRoot.alias = uniqueNameFromCollection(- createSlug(ev.name, true),+ alias,'alias',this.space.roots.filter((r: SpaceRootModel) => r.id !== spaceRoot.id)).toLowerCase()@@ -108,8 +120,7 @@ export class SpaceManageRootsComponent implements OnInit, OnDestroy {setRenamed(root: SpaceRootModel) {if (root.isRenamed) {- this.onRenameRoot({ object: root, name: this.inputRename.nativeElement.value })- root.isRenamed = false+ this.inputRename.nativeElement.blur()} else {root.isRenamed = true}diff --git a/frontend/src/i18n/de.json b/frontend/src/i18n/de.jsonindex d23caaff..99603a84 100644--- a/frontend/src/i18n/de.json+++ b/frontend/src/i18n/de.json@@ -588,6 +588,8 @@"Secret copied": "Geheimer Schlüssel kopiert","Recovery codes copied": "Wiederherstellungscodes kopiert","Invalid code": "Ungültiger Code",+ "Invalid name": "Ungültiger Name",+ "Name must contain at least one letter or number": "Der Name muss mindestens einen Buchstaben oder eine Zahl enthalten","Incorrect code or password": "Falscher Code oder falsches Passwort","Application Passwords": "Anwendungskennwörter","Generate a new app password": "Neues App‑Passwort generieren",diff --git a/frontend/src/i18n/es.json b/frontend/src/i18n/es.jsonindex 9e570faf..2adcca80 100644--- a/frontend/src/i18n/es.json+++ b/frontend/src/i18n/es.json@@ -588,6 +588,8 @@"Secret copied": "Secreto copiado","Recovery codes copied": "Códigos de recuperación copiados","Invalid code": "Código inválido",+ "Invalid name": "Nombre no válido",+ "Name must contain at least one letter or number": "El nombre debe contener al menos una letra o un número","Incorrect code or password": "Código o contraseña incorrectos","Application Passwords": "Contraseñas de aplicación","Generate a new app password": "Generar una nueva contraseña de aplicación",diff --git a/frontend/src/i18n/fr.json b/frontend/src/i18n/fr.jsonindex d2612a24..4d383ce8 100644--- a/frontend/src/i18n/fr.json+++ b/frontend/src/i18n/fr.json@@ -588,6 +588,8 @@"Secret copied": "Secret copié","Recovery codes copied": "Codes de récupération copiés","Invalid code": "Code invalide",+ "Invalid name": "Nom invalide",+ "Name must contain at least one letter or number": "Le nom doit contenir au moins une lettre ou un chiffre","Incorrect code or password": "Code ou mot de passe incorrect","Application Passwords": "Mots de passe d'application","Generate a new app password": "Générer un nouveau mot de passe d’application",diff --git a/frontend/src/i18n/hi.json b/frontend/src/i18n/hi.jsonindex b87c48be..00da11ed 100644--- a/frontend/src/i18n/hi.json+++ b/frontend/src/i18n/hi.json@@ -588,6 +588,8 @@"Secret copied": "सीक्रेट कॉपी हुआ","Recovery codes copied": "रिकवरी कोड कॉपी हुए","Invalid code": "अमान्य कोड",+ "Invalid name": "अमान्य नाम",+ "Name must contain at least one letter or number": "नाम में कम से कम एक अक्षर या संख्या होनी चाहिए","Incorrect code or password": "गलत कोड या पासवर्ड","Application Passwords": "एप्लिकेशन पासवर्ड","Generate a new app password": "नया ऐप पासवर्ड जनरेट करें",diff --git a/frontend/src/i18n/it.json b/frontend/src/i18n/it.jsonindex 496b50e6..426f62a7 100644--- a/frontend/src/i18n/it.json+++ b/frontend/src/i18n/it.json@@ -588,6 +588,8 @@"Secret copied": "Segreto copiato","Recovery codes copied": "Codici di recupero copiati","Invalid code": "Codice non valido",+ "Invalid name": "Nome non valido",+ "Name must contain at least one letter or number": "Il nome deve contenere almeno una lettera o un numero","Incorrect code or password": "Codice o password errati","Application Passwords": "Password delle applicazioni","Generate a new app password": "Genera una nuova password per l’applicazione",diff --git a/frontend/src/i18n/ja.json b/frontend/src/i18n/ja.jsonindex 771d95d8..235374ad 100644--- a/frontend/src/i18n/ja.json+++ b/frontend/src/i18n/ja.json@@ -588,6 +588,8 @@"Secret copied": "シークレットをコピーしました","Recovery codes copied": "復旧コードをコピーしました","Invalid code": "無効なコード",+ "Invalid name": "無効な名前",+ "Name must contain at least one letter or number": "名前には少なくとも1つの文字または数字を含める必要があります","Incorrect code or password": "コードまたはパスワードが正しくありません","Application Passwords": "アプリケーションパスワード","Generate a new app password": "新しいアプリパスワードを生成",diff --git a/frontend/src/i18n/ko.json b/frontend/src/i18n/ko.jsonindex b9c4c40c..d5c58892 100644--- a/frontend/src/i18n/ko.json+++ b/frontend/src/i18n/ko.json@@ -588,6 +588,8 @@"Secret copied": "시크릿이 복사되었습니다","Recovery codes copied": "복구 코드가 복사되었습니다","Invalid code": "잘못된 코드",+ "Invalid name": "잘못된 이름",+ "Name must contain at least one letter or number": "이름에는 문자 또는 숫자가 하나 이상 포함되어야 합니다","Incorrect code or password": "코드 또는 비밀번호가 올바르지 않습니다","Application Passwords": "애플리케이션 비밀번호","Generate a new app password": "새 앱 비밀번호 생성",diff --git a/frontend/src/i18n/nl.json b/frontend/src/i18n/nl.jsonindex ecfb8d5f..108a5596 100644--- a/frontend/src/i18n/nl.json+++ b/frontend/src/i18n/nl.json@@ -588,6 +588,8 @@"Secret copied": "Geheime sleutel gekopieerd","Recovery codes copied": "Herstelcodes gekopieerd","Invalid code": "Incorrecte code",+ "Invalid name": "Ongeldige naam",+ "Name must contain at least one letter or number": "De naam moet ten minste één letter of cijfer bevatten","Incorrect code or password": "Incorrecte code of wachtwoord","Application Passwords": "Toepassingswachtwoorden","Generate a new app password": "Nieuw App-wachtwoord genereren",diff --git a/frontend/src/i18n/pl.json b/frontend/src/i18n/pl.jsonindex 5f26b262..52c437a5 100644--- a/frontend/src/i18n/pl.json+++ b/frontend/src/i18n/pl.json@@ -588,6 +588,8 @@"Secret copied": "Skopiowano sekret","Recovery codes copied": "Skopiowano kody odzyskiwania","Invalid code": "Nieprawidłowy kod",+ "Invalid name": "Nieprawidłowa nazwa",+ "Name must contain at least one letter or number": "Nazwa musi zawierać co najmniej jedną literę lub cyfrę","Incorrect code or password": "Nieprawidłowy kod lub hasło","Application Passwords": "Hasła aplikacji","Generate a new app password": "Wygeneruj nowe hasło aplikacji",diff --git a/frontend/src/i18n/pt-BR.json b/frontend/src/i18n/pt-BR.jsonindex 0d38a127..92abf8b1 100644--- a/frontend/src/i18n/pt-BR.json+++ b/frontend/src/i18n/pt-BR.json@@ -588,6 +588,8 @@"Secret copied": "Segredo copiado","Recovery codes copied": "Códigos de recuperação copiados","Invalid code": "Código inválido",+ "Invalid name": "Nome inválido",+ "Name must contain at least one letter or number": "O nome deve conter pelo menos uma letra ou um número","Incorrect code or password": "Código ou senha incorretos","Application Passwords": "Senhas de aplicativo","Generate a new app password": "Gerar nova senha de aplicativo",diff --git a/frontend/src/i18n/pt.json b/frontend/src/i18n/pt.jsonindex 53109983..c5fb32fc 100644--- a/frontend/src/i18n/pt.json+++ b/frontend/src/i18n/pt.json@@ -588,6 +588,8 @@"Secret copied": "Segredo copiado","Recovery codes copied": "Códigos de recuperação copiados","Invalid code": "Código inválido",+ "Invalid name": "Nome inválido",+ "Name must contain at least one letter or number": "O nome deve conter pelo menos uma letra ou um número","Incorrect code or password": "Código ou senha incorretos","Application Passwords": "Senhas de aplicativo","Generate a new app password": "Gerar uma nova senha de aplicativo",diff --git a/frontend/src/i18n/ru.json b/frontend/src/i18n/ru.jsonindex a6bc8a78..abe35874 100644--- a/frontend/src/i18n/ru.json+++ b/frontend/src/i18n/ru.json@@ -588,6 +588,8 @@"Secret copied": "Секрет скопирован","Recovery codes copied": "Коды восстановления скопированы","Invalid code": "Неверный код",+ "Invalid name": "Недопустимое имя",+ "Name must contain at least one letter or number": "Имя должно содержать хотя бы одну букву или цифру","Incorrect code or password": "Неверный код или пароль","Application Passwords": "Пароли приложений","Generate a new app password": "Создать новый пароль приложения",diff --git a/frontend/src/i18n/tr.json b/frontend/src/i18n/tr.jsonindex 5ac46cc3..0bdb3aeb 100644--- a/frontend/src/i18n/tr.json+++ b/frontend/src/i18n/tr.json@@ -588,6 +588,8 @@"Secret copied": "Gizli anahtar kopyalandı","Recovery codes copied": "Kurtarma kodları kopyalandı","Invalid code": "Geçersiz kod",+ "Invalid name": "Geçersiz ad",+ "Name must contain at least one letter or number": "Ad en az bir harf veya rakam içermelidir","Incorrect code or password": "Kod veya parola yanlış","Application Passwords": "Uygulama Parolaları","Generate a new app password": "Yeni uygulama parolası oluştur",diff --git a/frontend/src/i18n/zh.json b/frontend/src/i18n/zh.jsonindex 1e8de3bf..f07d7675 100644--- a/frontend/src/i18n/zh.json+++ b/frontend/src/i18n/zh.json@@ -588,6 +588,8 @@"Secret copied": "密钥已复制","Recovery codes copied": "恢复代码已复制","Invalid code": "无效代码",+ "Invalid name": "名称无效",+ "Name must contain at least one letter or number": "名称必须至少包含一个字母或数字","Incorrect code or password": "代码或密码不正确","Application Passwords": "应用专用密码","Generate a new app password": "生成新的应用专用密码",