Browse Source

Merge pull request #15729 from abpframework/issue-15694

Encode URL before saving it into database
pull/15770/head
Engincan VESKE 3 years ago
committed by GitHub
parent
commit
9800a3f35c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml.cs
  2. 2
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml.cs

3
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml.cs

@ -50,6 +50,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
var postDto = await _postAppService.GetAsync(new Guid(PostId)); var postDto = await _postAppService.GetAsync(new Guid(PostId));
Post = ObjectMapper.Map<PostWithDetailsDto, EditPostViewModel>(postDto); Post = ObjectMapper.Map<PostWithDetailsDto, EditPostViewModel>(postDto);
Post.Tags = String.Join(", ", postDto.Tags.Select(p => p.Name).ToArray()); Post.Tags = String.Join(", ", postDto.Tags.Select(p => p.Name).ToArray());
Post.Url = WebUtility.UrlDecode(Post.Url);
return Page(); return Page();
} }
@ -60,7 +61,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
{ {
BlogId = Post.BlogId, BlogId = Post.BlogId,
Title = Post.Title, Title = Post.Title,
Url = Post.Url, Url = WebUtility.UrlEncode(Post.Url),
CoverImage = Post.CoverImage, CoverImage = Post.CoverImage,
Content = Post.Content, Content = Post.Content,
Tags = Post.Tags, Tags = Post.Tags,

2
modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/New.cshtml.cs

@ -66,6 +66,8 @@ namespace Volo.Blogging.Pages.Blog.Posts
Post.Description = Post.Content.Truncate(PostConsts.MaxSeoFriendlyDescriptionLength); Post.Description = Post.Content.Truncate(PostConsts.MaxSeoFriendlyDescriptionLength);
} }
Post.Url = WebUtility.UrlEncode(Post.Url);
var postWithDetailsDto = await _postAppService.CreateAsync(ObjectMapper.Map<CreatePostViewModel, CreatePostDto>(Post)); var postWithDetailsDto = await _postAppService.CreateAsync(ObjectMapper.Map<CreatePostViewModel, CreatePostDto>(Post));
//TODO: Try Url.Page(...) //TODO: Try Url.Page(...)

Loading…
Cancel
Save