Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add safe access to UrlReferrer in Log404 #3341

Merged
merged 2 commits into from
Dec 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions DNN Platform/Library/Entities/Urls/UrlRewriterUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,16 @@ public static void Log404(HttpRequest request, FriendlyUrlSettings settings, Url

if (request != null)
{
if (request.UrlReferrer != null)
try
{
log.LogProperties.Add(new LogDetailInfo("Referer", request.UrlReferrer.AbsoluteUri));
if (request.UrlReferrer != null)
{
log.LogProperties.Add(new LogDetailInfo("Referer", request.UrlReferrer.AbsoluteUri));
}
}
catch (UriFormatException)
{
log.LogProperties.Add(new LogDetailInfo("Referer", request.Headers["Referer"]));
}
log.LogProperties.Add(new LogDetailInfo("Url", request.Url.AbsoluteUri));
log.LogProperties.Add(new LogDetailInfo("UserAgent", request.UserAgent));
Expand Down Expand Up @@ -215,4 +222,4 @@ public static string CleanExtension(string value, FriendlyUrlSettings settings,
return RewriteController.CleanExtension(value, settings, langParms, out replaced);
}
}
}
}