Replies: 1 comment
-
|
It turns out that my AUM_IgnoreUrlRegex setting with DnnImageHandler.ashx($|?) caused HttpModule to ignore the PortalSettings. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description I encountered a potential NullReferenceException in the UserProfilePicTransform class while debugging the DNN Platform source code.
Specifically, in the method that handles the image transformation, PortalController.Instance.GetCurrentSettings() is called to retrieve the current portal settings. Immediately after, the code attempts to access settings.PortalId.
If GetCurrentSettings() returns null (which can happen if the Image Handler is requested in a context where the Portal Settings are not correctly resolved, e.g., missing alias or direct handler request), the application throws an exception.
Location
File: DNN Platform/Library/Services/GeneratedImage/StartTransform/UserProfilePicTransform.cs
Lines: ~78-79 (depending on the version)
https://github.com/dnnsoftware/Dnn.Platform/blob/8ceb145f4e478552a20484d0cb2b607d16ca5d97/DNN%20Platform/Library/Services/GeneratedImage/StartTransform/UserProfilePicTransform.cs#L78C13-L79
var settings = PortalController.Instance.GetCurrentSettings(); var targetUser = UserController.Instance.GetUser(settings.PortalId, this.UserID);Steps to Reproduce
Debug the UserProfilePicTransform.cs file.
Trigger an image transformation request in a scenario where the HttpContext or PortalAlias is not fully resolved (causing GetCurrentSettings() to return null).
login as host user, and browser request url
https://dnndev.me/DnnImageHandler.ashx?mode=profilepic&userId=1&h=32&w=32&cdv=639040729629470000
Observe the crash at settings.PortalId.
Expected Behavior The code should perform a null check on settings before accessing its properties. If settings is null, the transformation should gracefully abort or use a fallback mechanism instead of throwing an unhandled exception.
Beta Was this translation helpful? Give feedback.
All reactions