Browse Source

Encode URL before saving it into database

pull/15729/head
Salih 3 years ago
parent
commit
a8284c0bf1
  1. 3
      modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Edit.cshtml.cs
  2. 3
      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));
Post = ObjectMapper.Map<PostWithDetailsDto, EditPostViewModel>(postDto);
Post.Tags = String.Join(", ", postDto.Tags.Select(p => p.Name).ToArray());
Post.Url = WebUtility.UrlDecode(Post.Url);
return Page();
}
@ -60,7 +61,7 @@ namespace Volo.Blogging.Pages.Blog.Posts
{
BlogId = Post.BlogId,
Title = Post.Title,
Url = Post.Url,
Url = WebUtility.UrlEncode(Post.Url),
CoverImage = Post.CoverImage,
Content = Post.Content,
Tags = Post.Tags,

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

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

Loading…
Cancel
Save