mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
Desktop: Fix "open profile directory" shows a warning message (#10294)
This commit is contained in:
parent
2ae08ff46e
commit
238683e36f
@ -362,7 +362,7 @@ export class Bridge {
|
||||
if (await pathExists(fullPath)) {
|
||||
const fileExtension = extname(fullPath);
|
||||
const userAllowedExtension = this.extraAllowedOpenExtensions.includes(fileExtension);
|
||||
if (userAllowedExtension || isSafeToOpen(fullPath)) {
|
||||
if (userAllowedExtension || await isSafeToOpen(fullPath)) {
|
||||
return shell.openPath(fullPath);
|
||||
} else {
|
||||
const allowOpenId = 2;
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { remove, writeFile } from 'fs-extra';
|
||||
import { createTempDir } from '@joplin/lib/testing/test-utils';
|
||||
import { join } from 'path';
|
||||
import isUnsafeToOpen from './isSafeToOpen';
|
||||
import isSafeToOpen from './isSafeToOpen';
|
||||
|
||||
|
||||
describe('isUnsafeToOpen', () => {
|
||||
describe('isSafeToOpen', () => {
|
||||
test.each([
|
||||
{ fileName: 'a.txt', expected: true },
|
||||
{ fileName: 'a.json', expected: true },
|
||||
@ -24,7 +24,7 @@ describe('isUnsafeToOpen', () => {
|
||||
try {
|
||||
const fullPath = join(tempDir, fileName);
|
||||
await writeFile(fullPath, 'test');
|
||||
expect(await isUnsafeToOpen(fullPath)).toBe(expected);
|
||||
expect(await isSafeToOpen(fullPath)).toBe(expected);
|
||||
} finally {
|
||||
await remove(tempDir);
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
import { stat } from 'fs-extra';
|
||||
import { extname } from 'path';
|
||||
|
||||
|
||||
const isSafeToOpen = (path: string) => {
|
||||
const isSafeToOpen = async (path: string) => {
|
||||
// This is intended to fix an issue where some platforms would execute attachment
|
||||
// files without confirmation depending on the file extension (e.g. .EXE). This is
|
||||
// mostly for Windows.
|
||||
@ -173,6 +175,11 @@ const isSafeToOpen = (path: string) => {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (extname(path) === '' && (await stat(path)).isDirectory()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user