Playlists: Fix 'invalid byte sequence' error when subscribing (#4887)
In Crystal, handling multi-byte sequences in UTF-8 requires understanding that slicing by bytes can lead to invalid sequences if the slicing isn't aligned with character boundaries. In this case, attempting to slice a string by bytes can cut through multi-byte UTF-8 sequences, leading to invalid sequences. To avoid this, strings should be sliced based on characters rather than bytes. Fixes issue 4886
This commit is contained in:
commit
97895a491a
@ -270,7 +270,7 @@ end
|
|||||||
|
|
||||||
def subscribe_playlist(user, playlist)
|
def subscribe_playlist(user, playlist)
|
||||||
playlist = InvidiousPlaylist.new({
|
playlist = InvidiousPlaylist.new({
|
||||||
title: playlist.title.byte_slice(0, 150),
|
title: playlist.title[..150],
|
||||||
id: playlist.id,
|
id: playlist.id,
|
||||||
author: user.email,
|
author: user.email,
|
||||||
description: "", # Max 5000 characters
|
description: "", # Max 5000 characters
|
||||||
|
Loading…
Reference in New Issue
Block a user