dnnsoftware / Dnn.Platform

DNN (formerly DotNetNuke) is the leading open source web content management platform (CMS) in the Microsoft ecosystem.
https://dnncommunity.org/
MIT License
1.03k stars 751 forks source link

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

Open WillStrohl opened 1 year ago

WillStrohl commented 1 year ago

Is there an existing issue for this?

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

PabloSR06 commented 1 year ago

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.

bdukes commented 1 year ago

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!

WillStrohl commented 1 year ago

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