1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 01:27:29 +08:00

Parse HTML entities during APINewsPost deserialisation

This commit is contained in:
Andrei Zavatski 2020-07-07 00:11:35 +03:00
parent c86bb2e755
commit 857a027a73
2 changed files with 25 additions and 6 deletions

View File

@ -39,9 +39,9 @@ namespace osu.Game.Tests.Visual.Online
}),
new NewsCard(new APINewsPost
{
Title = "This post has a full-url image!",
Preview = "boom",
Author = "user",
Title = "This post has a full-url image! (HTML entity: &)",
Preview = "boom (HTML entity: &)",
Author = "user (HTML entity: &)",
FirstImage = "https://assets.ppy.sh/artists/88/header.jpg",
PublishedAt = DateTimeOffset.Now
})

View File

@ -3,6 +3,7 @@
using Newtonsoft.Json;
using System;
using System.Net;
namespace osu.Game.Online.API.Requests.Responses
{
@ -11,8 +12,14 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("id")]
public long Id { get; set; }
private string author;
[JsonProperty("author")]
public string Author { get; set; }
public string Author
{
get => author;
set => author = WebUtility.HtmlDecode(value);
}
[JsonProperty("edit_url")]
public string EditUrl { get; set; }
@ -29,10 +36,22 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonProperty("slug")]
public string Slug { get; set; }
private string title;
[JsonProperty("title")]
public string Title { get; set; }
public string Title
{
get => title;
set => title = WebUtility.HtmlDecode(value);
}
private string preview;
[JsonProperty("preview")]
public string Preview { get; set; }
public string Preview
{
get => preview;
set => preview = WebUtility.HtmlDecode(value);
}
}
}