Skip to content

Commit d03acc1

Browse files
committed
Throw a 403 error if a Container is requested
`Container` topics are topics used to help organize topics. They are not meant to be viewed directly, and are not expected to have pages associated with them. In a recent update, we excluded `Container` topics from the `Sitemap` (87b6d1b), so they shouldn't be referenced, but they may still be discoverable as interstitial folders.
1 parent 85216c4 commit d03acc1

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

OnTopic.AspNetCore.Mvc/ValidateTopicAttribute.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,17 @@ public override void OnActionExecuting(ActionExecutingContext filterContext) {
116116
return;
117117
}
118118

119+
/*------------------------------------------------------------------------------------------------------------------------
120+
| Handle containers
121+
>-------------------------------------------------------------------------------------------------------------------------
122+
| Like nested topics, containers are not expected to be viewed directly; if a user requests a container, return a 403 to
123+
| indicate that the request is valid, but forbidden. Unlike nested topics, children of containers are potentially valid.
124+
\-----------------------------------------------------------------------------------------------------------------------*/
125+
if (currentTopic.ContentType == "Container") {
126+
filterContext.Result = new StatusCodeResult(403);
127+
return;
128+
}
129+
119130
/*------------------------------------------------------------------------------------------------------------------------
120131
| Handle page groups
121132
>-------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)