!337 检查增强

Merge pull request !337 from 孟立/master
This commit is contained in:
openharmony_ci 2024-11-12 05:17:15 +00:00 committed by Gitee
commit f7db952865
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 18 additions and 0 deletions

View File

@ -33,6 +33,7 @@ import {
toggleShow,
directionStatus,
getTime,
isValidPath,
sendDlpManagerFileConfiguration
} from '../common/utils';
import { DlpAlertDialog } from '../common/components/dlp_alert_dialog';
@ -216,6 +217,10 @@ struct changeEncryption {
HiLog.info(TAG, `Decrypt DLP file: ${this.srcFileName}`);
try {
let srcFileUri: string = GlobalContext.load('uri');
if (!isValidPath(srcFileUri)) {
HiLog.error(TAG, `uri is invalid`);
return;
}
let srcFileMsg: FileMsg = FileUtils.getAllSuffixByUri(srcFileUri);
let documentSaveOptions = new picker.DocumentSaveOptions();
documentSaveOptions.newFileNames = [decodeURIComponent(plaintextFile)];
@ -245,6 +250,10 @@ struct changeEncryption {
async fileDecryption(saveRes: Array<string>): Promise<void> {
let plainUri = saveRes[0];
if (!isValidPath(plainUri)) {
HiLog.error(TAG, `pick save uri is invalid`);
return;
}
let uriInfo: fileUri.FileUri | undefined = undefined;
let file: fs.File | undefined = undefined;
try {

View File

@ -37,6 +37,7 @@ import {
getFileUriByPath,
sendDlpFileCreateProperties,
sendDlpManagerFileConfiguration,
isValidPath,
getFileSizeByUri
} from '../common/utils';
import Constants from '../common/constant';
@ -366,6 +367,10 @@ struct DlpDialog {
await this.setUserStat();
try {
let srcFileUri: string = GlobalContext.load('uri');
if (!isValidPath(srcFileUri)) {
HiLog.error(TAG, `uri is invalid`);
return;
}
let srcFileMsg: FileMsg = FileUtils.getSuffixFileMsgByUri(srcFileUri);
let srcFileSize: number = await getFileSizeByUri(srcFileUri);
AppStorage.setOrCreate('hiFileSize', srcFileSize);
@ -385,6 +390,10 @@ struct DlpDialog {
}
HiLog.info(TAG, `get uri success`);
uri = saveRes[0];
if (!isValidPath(uri)) {
HiLog.error(TAG, `pick save uri is invalid`);
return;
}
let uriInfo: fileUri.FileUri = new fileUri.FileUri('');
try {
uriInfo = new fileUri.FileUri(uri);