mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Use Base64Url form for paths. (#556)
This commit is contained in:
parent
5b8cebfc21
commit
df8b5658a7
@ -27,6 +27,7 @@ using Kyoo.Abstractions.Models.Permissions;
|
||||
using Kyoo.Abstractions.Models.Utils;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.WebUtilities;
|
||||
|
||||
namespace Kyoo.Core.Api;
|
||||
|
||||
@ -54,7 +55,7 @@ public abstract class TranscoderApi<T>(IRepository<T> repository) : CrudThumbsAp
|
||||
private async Task<string> _GetPath64(Identifier identifier)
|
||||
{
|
||||
string path = await GetPath(identifier);
|
||||
return Convert.ToBase64String(Encoding.UTF8.GetBytes(path));
|
||||
return WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(path));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,9 +24,9 @@ func GetPath(c echo.Context) (string, string, error) {
|
||||
if key == "" {
|
||||
return "", "", echo.NewHTTPError(http.StatusBadRequest, "Missing resouce path.")
|
||||
}
|
||||
pathb, err := base64.StdEncoding.DecodeString(key)
|
||||
pathb, err := base64.RawURLEncoding.DecodeString(key)
|
||||
if err != nil {
|
||||
return "", "", echo.NewHTTPError(http.StatusBadRequest, "Invalid path. Should be base64 encoded.")
|
||||
return "", "", echo.NewHTTPError(http.StatusBadRequest, "Invalid path. Should be base64url (without padding) encoded.")
|
||||
}
|
||||
path := filepath.Clean(string(pathb))
|
||||
if !filepath.IsAbs(path) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user