Skip to content

Commit

Permalink
Merge pull request #608 from poppastring/security-fix-rss-category
Browse files Browse the repository at this point in the history
RSS category security fix
  • Loading branch information
poppastring authored Jan 22, 2022
2 parents 9bbd2a6 + 34557a7 commit 423546c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions source/DasBlog.Web.UI/Controllers/FeedController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,27 @@ public IActionResult Rss()
memoryCache.Set(CACHEKEY_RSS, rss, SiteCacheSettings());
}

logger.LogInformation(new EventDataItem(EventCodes.RSS, null, "RSS request"));

return Ok(rss);
}

[Produces("text/xml")]
[HttpGet("feed/rss/{category}"), HttpHead("feed/rss/{category}")]
public IActionResult RssByCategory(string category)
{

if (!memoryCache.TryGetValue(CACHEKEY_RSS + "_" + category, out RssRoot rss))
{
rss = subscriptionManager.GetRssCategory(category);

memoryCache.Set(CACHEKEY_RSS + "_" + category, rss, SiteCacheSettings());
if (rss.Channels[0]?.Items?.Count > 0)
{
memoryCache.Set(CACHEKEY_RSS + "_" + category, rss, SiteCacheSettings());
}
}

logger.LogInformation(new EventDataItem(EventCodes.RSS, null, "RSS category request: '{0}'", category));
if(rss.Channels[0]?.Items?.Count == 0)
{
return NoContent();
}

return Ok(rss);
}
Expand Down Expand Up @@ -106,8 +109,6 @@ public async Task<IActionResult> BloggerPost()
logger.LogError(new EventDataItem(EventCodes.RSS, null, "FeedController.BloggerPost Error: {0}", ex.Message));
}

logger.LogInformation(new EventDataItem(EventCodes.RSS, null, "FeedController.BloggerPost successfully submitted"));

BreakSiteCache();

return Content(blogger);
Expand Down

0 comments on commit 423546c

Please sign in to comment.