mirror of
https://github.com/immich-app/immich.git
synced 2025-01-06 03:46:47 +01:00
fix(server): normalize external path (#4239)
* fix: use normalized external path * fix: move normalization to user core
This commit is contained in:
parent
35fa6397ea
commit
4dffae3f39
2 changed files with 4 additions and 1 deletions
|
@ -155,7 +155,7 @@ export class LibraryService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path.normalize(assetPath).match(new RegExp(`^${user.externalPath}`))) {
|
if (!path.normalize(assetPath).match(new RegExp(`^${path.normalize(user.externalPath)}`))) {
|
||||||
this.logger.error("Asset must be within the user's external path");
|
this.logger.error("Asset must be within the user's external path");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import {
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { ReadStream, constants, createReadStream } from 'fs';
|
import { ReadStream, constants, createReadStream } from 'fs';
|
||||||
import fs from 'fs/promises';
|
import fs from 'fs/promises';
|
||||||
|
import path from 'path';
|
||||||
import sanitize from 'sanitize-filename';
|
import sanitize from 'sanitize-filename';
|
||||||
import { AuthUserDto } from '../auth';
|
import { AuthUserDto } from '../auth';
|
||||||
import { ICryptoRepository } from '../crypto';
|
import { ICryptoRepository } from '../crypto';
|
||||||
|
@ -63,6 +64,8 @@ export class UserCore {
|
||||||
|
|
||||||
if (dto.externalPath === '') {
|
if (dto.externalPath === '') {
|
||||||
dto.externalPath = null;
|
dto.externalPath = null;
|
||||||
|
} else if (dto.externalPath) {
|
||||||
|
dto.externalPath = path.normalize(dto.externalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.userRepository.update(id, dto);
|
return this.userRepository.update(id, dto);
|
||||||
|
|
Loading…
Reference in a new issue