improve filename validation in module content export
This commit is contained in:
@ -50,6 +50,11 @@
|
||||
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
|
||||
public override string Title => "Export Content";
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_filename = Utilities.GetFriendlyUrl(ModuleState.Title);
|
||||
}
|
||||
|
||||
private async Task ExportText()
|
||||
{
|
||||
try
|
||||
@ -71,8 +76,8 @@
|
||||
var folderid = _filemanager.GetFolderId();
|
||||
if (folderid != -1 && !string.IsNullOrEmpty(_filename))
|
||||
{
|
||||
var result = await ModuleService.ExportModuleAsync(ModuleState.ModuleId, PageState.Page.PageId, folderid, _filename);
|
||||
if (result.Success)
|
||||
var fileid = await ModuleService.ExportModuleAsync(ModuleState.ModuleId, PageState.Page.PageId, folderid, _filename);
|
||||
if (fileid != -1)
|
||||
{
|
||||
AddModuleMessage(Localizer["Success.Content.Export"], MessageType.Success);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace Oqtane.Services
|
||||
/// <param name="pageId"></param>
|
||||
/// <param name="folderId"></param>
|
||||
/// <param name="filename"></param>
|
||||
/// <returns>success/failure</returns>
|
||||
Task<Result> ExportModuleAsync(int moduleId, int pageId, int folderId, string filename);
|
||||
/// <returns>file id</returns>
|
||||
Task<int> ExportModuleAsync(int moduleId, int pageId, int folderId, string filename);
|
||||
}
|
||||
}
|
||||
|
@ -51,9 +51,9 @@ namespace Oqtane.Services
|
||||
return await GetStringAsync($"{Apiurl}/export?moduleid={moduleId}&pageid={pageId}");
|
||||
}
|
||||
|
||||
public async Task<Result> ExportModuleAsync(int moduleId, int pageId, int folderId, string filename)
|
||||
public async Task<int> ExportModuleAsync(int moduleId, int pageId, int folderId, string filename)
|
||||
{
|
||||
return await PostJsonAsync<Result>($"{Apiurl}/export?moduleid={moduleId}&pageid={pageId}&folderid={folderId}&filename={filename}", null);
|
||||
return await PostJsonAsync<string,int>($"{Apiurl}/export?moduleid={moduleId}&pageid={pageId}&folderid={folderId}&filename={filename}", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user