Fileformat blogshort name requests are suppressed

pull/3720/head
Ahmet 6 years ago
parent d358e80ecb
commit 9a63888809

@ -1,8 +1,7 @@
using System;
using Microsoft.AspNetCore.Authorization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Blogging.Blogs.Dtos;
@ -33,13 +32,6 @@ namespace Volo.Blogging.Blogs
if (blog == null)
{
FileInfo fi = new FileInfo(shortName);
if (!string.IsNullOrEmpty(fi.Extension))
{
return null;
}
throw new EntityNotFoundException(typeof(Blog), shortName);
}

@ -8,6 +8,7 @@ using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Comments;
using Volo.Blogging.Comments.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts;
namespace Volo.Blogging.Pages.Blog.Posts
@ -48,6 +49,11 @@ namespace Volo.Blogging.Pages.Blog.Posts
public virtual async Task<IActionResult> OnGetAsync()
{
if (BlogNameControlHelper.IsFileFormat(BlogShortName))
{
return NotFound();
}
await GetData();
return Page();

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Blogging.Blogs;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts;
namespace Volo.Blogging.Pages.Blog.Posts
@ -39,6 +40,10 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
return Redirect("/");
}
if (BlogNameControlHelper.IsFileFormat(BlogShortName))
{
return NotFound();
}
var postDto = await _postAppService.GetAsync(new Guid(PostId));
Post = ObjectMapper.Map<PostWithDetailsDto, EditPostViewModel>(postDto);

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts;
using Volo.Blogging.Tagging;
using Volo.Blogging.Tagging.Dtos;
@ -37,6 +38,11 @@ namespace Volo.Blogging.Pages.Blog.Posts
public virtual async Task<ActionResult> OnGetAsync()
{
if (BlogNameControlHelper.IsFileFormat(BlogShortName))
{
return NotFound();
}
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Posts = (await _postAppService.GetListByBlogIdAndTagName(Blog.Id, TagName)).Items;
PopularTags = (await _tagAppService.GetPopularTags(Blog.Id, new GetPopularTagsInput {ResultCount = 10, MinimumPostCount = 2}));

@ -8,6 +8,7 @@ using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using Volo.Blogging.Blogs;
using Volo.Blogging.Blogs.Dtos;
using Volo.Blogging.Pages.Blogs.Shared.Helpers;
using Volo.Blogging.Posts;
namespace Volo.Blogging.Pages.Blog.Posts
@ -41,6 +42,10 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
return Redirect("/");
}
if (BlogNameControlHelper.IsFileFormat(BlogShortName))
{
return NotFound();
}
Blog = await _blogAppService.GetByShortNameAsync(BlogShortName);
Post = new CreatePostViewModel

@ -0,0 +1,23 @@
using System.IO;
using Microsoft.AspNetCore.Mvc;
namespace Volo.Blogging.Pages.Blogs.Shared.Helpers
{
public static class BlogNameControlHelper
{
public static bool IsFileFormat(string blogShortName)
{
if (!string.IsNullOrWhiteSpace(blogShortName))
{
var fileInfo = new FileInfo(blogShortName);
if (!string.IsNullOrEmpty(fileInfo.Extension))
{
return true;
}
}
return false;
}
}
}
Loading…
Cancel
Save