mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-10-26 16:45:09 +00:00
Backport pull request #18096 from jellyfin/release-12.z
Decode HTML entities in OMDb responses
Original-merge: 8bd7306fc9
Merged-by: crobibero <cody@robibe.ro>
Backported-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
1 parent
b1787cbc36
commit
dcc7b6dde9
4 files changed
+54
-10
No files matched your search
@@ -63,6 +63,41 @@ namespace Jellyfin.Providers.Tests.Omdb
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("\"Vincent D'Onofrio\"", "Vincent D'Onofrio")]
|
||||
[InlineData("\"Alan Moore 'Swamp Thing'\"", "Alan Moore 'Swamp Thing'")]
|
||||
[InlineData("\"Tom & Jerry\"", "Tom & Jerry")]
|
||||
[InlineData("\"Mail <a@b.com> for a translation\"", "Mail <a@b.com> for a translation")]
|
||||
[InlineData("\"Elisa Mont\\u00e9s\"", "Elisa Montés")]
|
||||
[InlineData("\"R&D and 100% & more\"", "R&D and 100% & more")]
|
||||
public void Deserialize_Html_Encoded_String_Is_Decoded(string input, string expected)
|
||||
{
|
||||
var result = JsonSerializer.Deserialize<string?>(input, _options);
|
||||
Assert.Equal(expected, result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Deserialize_Html_Encoded_Credits_Are_Decoded()
|
||||
{
|
||||
const string Input = "{\"Title\":\"Full Metal Jacket\",\"Actors\":\"Matthew Modine, R. Lee Ermey, Vincent D'Onofrio\",\"Response\":\"True\"}";
|
||||
var rootObject = JsonSerializer.Deserialize<OmdbProvider.RootObject>(Input, _options);
|
||||
Assert.NotNull(rootObject);
|
||||
Assert.Equal("Matthew Modine, R. Lee Ermey, Vincent D'Onofrio", rootObject!.Actors);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ProviderJsonOptions_Take_Priority_Over_The_Defaults()
|
||||
{
|
||||
// The default string converter handles string as well, so appending the OMDb ones would never run them
|
||||
var options = OmdbProvider.CreateJsonOptions();
|
||||
|
||||
const string Input = "{\"Title\":\"Full Metal Jacket\",\"Actors\":\"Vincent D'Onofrio\",\"Awards\":\"N/A\",\"Response\":\"True\"}";
|
||||
var rootObject = JsonSerializer.Deserialize<OmdbProvider.RootObject>(Input, options);
|
||||
Assert.NotNull(rootObject);
|
||||
Assert.Equal("Vincent D'Onofrio", rootObject!.Actors);
|
||||
Assert.Null(rootObject.Awards);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Roundtrip_Valid_Success()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user