Dnn.Platform icon indicating copy to clipboard operation
Dnn.Platform copied to clipboard

[Bug]: Using the Azure Storage Provider Creates Bad Links in Resource Manager

Open WillStrohl opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What happened?

We enabled the built-in Azure Storage connector, then connected it to an Azure blog storage location. After synchronizing the files, the resulting links in the Resource Manager are prepended with the portal alias. These URLs are already fully qualified URLs.

Steps to reproduce?

  1. Install latest version of DNN.
  2. Create and configure an Azure Blob storage container with appropriate API keys.
  3. Connect the Azure Storage connector in DNN to the Azure Blob.
  4. Go to the Resource Manager and choose to synchronize the folders.

Current Behavior

THe folders appear, but clicking on a file to see the URL will yield a surprising result. The URLs for all cloud files have the portal alias prepended to it, creating a bad link.

The URL looks something like this:

https://www.example.comhttps//BLOBLNAME.blob.core.windows.net/FOLDERNAME/FILENAME.png?sv=2023-08-25&sr=b&si=DNNFileManagerPolicy&sig=53MzIMXOjSVgjwYcqYECZet%2Fxh%2F%2WIWWH%2Fue0ja7HD073A%3D

Expected Behavior

The generated URL is correct and can be used.

The actual URL should be this:

https//BLOBLNAME.blob.core.windows.net/FOLDERNAME/FILENAME.png?sv=2023-08-25&sr=b&si=DNNFileManagerPolicy&sig=53MzIMXOjSVgjwYcqYECZet%2Fxh%2F%2WIWWH%2Fue0ja7HD073A%3D

Relevant log output

N/A

Anything else?

No response

Affected Versions

9.12.0 (latest release)

What browsers are you seeing the problem on?

Firefox, Chrome, Safari, Microsoft Edge

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

WillStrohl avatar Aug 25 '23 19:08 WillStrohl

Hello, I found out why this happened.

This comes from a javascript file that handles the "Copy Url" option, I'm still trying to find where the js files come from. But if you open the js file directly "\DesktopModules\ResourceManager\Scripts\dnn-resource-manager\p-cd690c99.entry.js".

The problem is in this part of the code. image

My solution in this case was: image

This is because the element containing the file data contains the full azure storage path but the path relative to the web then this part of the javascript takes care of that adding the protocol and the host. As I said I am still understanding how this project works and I don't know where these js are being generated but this can work as a hot-fix.

PabloSR06 avatar Sep 20 '23 14:09 PabloSR06

Searching for navigator.clipboard.writeText in the project leads me to the source of that JS: https://github.com/dnnsoftware/Dnn.Platform/blob/a2014252657bae998c50eedfbef185dc2cde06d4/DNN%20Platform/Modules/ResourceManager/ResourceManager.Web/src/components/actions/dnn-action-copy-url/dnn-action-copy-url.tsx#L14-L17

We'd welcome a PR with a fix. I might just check for // or : rather than http, but otherwise that looks like a solid fix. Thanks for tracking it down!

bdukes avatar Sep 20 '23 14:09 bdukes

Great stuff... Thanks, @PabloSR06 & @bdukes!

WillStrohl avatar Sep 21 '23 15:09 WillStrohl