Skip to content

Commit

Permalink
bug 65568
Browse files Browse the repository at this point in the history
restore old values, if error
  • Loading branch information
pavelbannov committed Jan 18, 2024
1 parent 124019e commit de52634
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions products/ASC.Files/Server/Api/EditorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,35 @@ public EditorController(
public async Task<DocServiceUrlDto> CheckDocServiceUrl(CheckDocServiceUrlRequestDto inDto)
{
await _permissionContext.DemandPermissionsAsync(SecurityConstants.EditPortalSettings);

var currentDocServiceUrl = _filesLinkUtility.DocServiceUrl;
var currentDocServiceUrlInternal = _filesLinkUtility.DocServiceUrlInternal;
var currentDocServicePortalUrl = _filesLinkUtility.DocServicePortalUrl;

_filesLinkUtility.DocServiceUrl = inDto.DocServiceUrl;
_filesLinkUtility.DocServiceUrlInternal = inDto.DocServiceUrlInternal;
_filesLinkUtility.DocServicePortalUrl = inDto.DocServiceUrlPortal;

await _messageService.SendAsync(MessageAction.DocumentServiceLocationSetting);

var https = new Regex(@"^https://", RegexOptions.IgnoreCase);
var http = new Regex(@"^http://", RegexOptions.IgnoreCase);
if (https.IsMatch(_commonLinkUtility.GetFullAbsolutePath("")) && http.IsMatch(_filesLinkUtility.DocServiceUrl))
{
throw new Exception("Mixed Active Content is not allowed. HTTPS address for Document Server is required.");
}

await _documentServiceConnector.CheckDocServiceUrlAsync();
try
{
await _documentServiceConnector.CheckDocServiceUrlAsync();

await _messageService.SendAsync(MessageAction.DocumentServiceLocationSetting);
}
catch (Exception)
{
_filesLinkUtility.DocServiceUrl = currentDocServiceUrl;
_filesLinkUtility.DocServiceUrlInternal = currentDocServiceUrlInternal;
_filesLinkUtility.DocServicePortalUrl = currentDocServicePortalUrl;
throw;
}

return await GetDocServiceUrlAsync(false);
}
Expand Down

0 comments on commit de52634

Please sign in to comment.