Skip to content

Commit 76b8914

Browse files
committed
Improve Lbp1PlaylistEndpoints.ValidateIconHash()
1 parent bf646a7 commit 76b8914

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

Refresh.Interfaces.Game/Endpoints/Playlists/Lbp1PlaylistEndpoints.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,29 @@ public class Lbp1PlaylistEndpoints : EndpointGroup
2929
private const string UpdateBucket = PlaylistEndpointLimits.UpdateBucket;
3030

3131
/// <summary>
32-
/// Returns a blank hash (0) if the given reference is a GUID which doesn't reference a texture,
33-
/// or a hash referencing an asset which doesn't exist on the server.
34-
/// Returns the passed icon reference if nothing is wrong with it.
35-
/// Don't reject requests with invalid icons, as users normally can't control what icon the game will
36-
/// include in creation requests, and root playlist creation requests will be spammed + softlock the game
37-
/// until the server returns a successful response.
32+
/// Validate the playlist icon. If it's blank, an invalid GUID or a remote asset which doesn't exist on the server, reset to blank hash
33+
/// and do not return an error to not upset the game in certain cases (also because the user cannot choose the icon when creating a playlist).
3834
/// </summary>
3935
private string ValidateIconHash(string iconHash, DataContext dataContext)
4036
{
41-
if (!string.IsNullOrWhiteSpace(iconHash) && iconHash != "0")
37+
if (iconHash.IsBlankHash())
4238
{
43-
if (iconHash.StartsWith('g'))
44-
{
45-
//Parse out the GUID
46-
long guid = long.Parse(iconHash.AsSpan()[1..]);
47-
48-
if (!dataContext.GuidChecker.IsTextureGuid(dataContext.Game, guid))
49-
{
50-
return "0";
51-
}
52-
}
53-
else if (!dataContext.DataStore.ExistsInStore(iconHash))
39+
return "0";
40+
}
41+
else if (iconHash.StartsWith('g'))
42+
{
43+
//Parse out the GUID
44+
long guid = long.Parse(iconHash.AsSpan()[1..]);
45+
46+
if (!dataContext.GuidChecker.IsTextureGuid(dataContext.Game, guid))
5447
{
5548
return "0";
5649
}
5750
}
51+
else if (!dataContext.DataStore.ExistsInStore(iconHash))
52+
{
53+
return "0";
54+
}
5855

5956
return iconHash;
6057
}

0 commit comments

Comments
 (0)