mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
refactor(controllers): strip sensitive query parameters from stream URLs
Add StripLampacArgs method to remove account_email, uid, and nws_id parameters from streaming URLs before processing. This enhances privacy by preventing user identification data from being passed through to external services. The change is applied across all controllers that handle stream URL generation.
This commit is contained in:
parent
b91e7b0eac
commit
e846ce65b3
@ -161,7 +161,7 @@ namespace AnimeON.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
string playUrl = HostStreamProxy(init, accsArgs(streamLink));
|
||||
string playUrl = BuildStreamUrl(init, streamLink, headers: null, forceProxy: false);
|
||||
episode_tpl.Append(episodeName, title ?? original_title, seasonStr, episodeStr, playUrl);
|
||||
}
|
||||
}
|
||||
@ -217,7 +217,7 @@ namespace AnimeON.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
tpl.Append(translationName, HostStreamProxy(init, accsArgs(streamLink)));
|
||||
tpl.Append(translationName, BuildStreamUrl(init, streamLink, headers: null, forceProxy: false));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -376,9 +376,30 @@ namespace AnimeON.Controllers
|
||||
return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink, List<HeadersModel> headers, bool forceProxy)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
|
||||
@ -121,7 +121,10 @@ namespace Bamboo.Controllers
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = StripLampacArgs(streamLink?.Trim());
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
@ -135,5 +138,21 @@ namespace Bamboo.Controllers
|
||||
|
||||
return HostStreamProxy(init, link);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,7 +388,10 @@ namespace CikavaIdeya.Controllers
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = StripLampacArgs(streamLink?.Trim());
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
@ -402,5 +405,21 @@ namespace CikavaIdeya.Controllers
|
||||
|
||||
return HostStreamProxy(init, link);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -400,9 +400,30 @@ namespace Makhno
|
||||
await invoke.PostWormholeAsync(payload);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
private string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
|
||||
@ -116,7 +116,7 @@ namespace Mikai.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
string playUrl = HostStreamProxy(init, accsArgs(streamLink));
|
||||
string playUrl = BuildStreamUrl(init, streamLink, headers: null, forceProxy: false);
|
||||
episodeTpl.Append(episodeName, displayTitle, s.ToString(), ep.Number.ToString(), playUrl);
|
||||
}
|
||||
}
|
||||
@ -142,7 +142,7 @@ namespace Mikai.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
string playUrl = HostStreamProxy(init, accsArgs(episode.Url));
|
||||
string playUrl = BuildStreamUrl(init, episode.Url, headers: null, forceProxy: false);
|
||||
movieTpl.Append(voice.DisplayName, playUrl);
|
||||
}
|
||||
}
|
||||
@ -367,9 +367,30 @@ namespace Mikai.Controllers
|
||||
streamLink.Contains("moonanime.art", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
private string BuildStreamUrl(OnlinesSettings init, string streamLink, List<HeadersModel> headers, bool forceProxy)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
|
||||
@ -169,7 +169,10 @@ namespace StarLight.Controllers
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = StripLampacArgs(streamLink?.Trim());
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
@ -184,6 +187,22 @@ namespace StarLight.Controllers
|
||||
return HostStreamProxy(init, link, proxy: proxyManager.Get());
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
private static string GetSeasonNumber(SeasonInfo season, int fallbackIndex)
|
||||
{
|
||||
if (season?.Title == null)
|
||||
|
||||
@ -92,7 +92,7 @@ namespace UAKino.Controllers
|
||||
string callUrl = $"{host}/uakino/play?url={HttpUtility.UrlEncode(ep.Url)}&title={HttpUtility.UrlEncode(title ?? original_title)}";
|
||||
if (!string.IsNullOrEmpty(ep.Url) && ep.Url.Contains("ashdi.vip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string playUrl = HostStreamProxy(init, accsArgs(ep.Url));
|
||||
string playUrl = BuildStreamUrl(init, ep.Url);
|
||||
episode_tpl.Append(
|
||||
episodeName,
|
||||
title ?? original_title,
|
||||
@ -165,9 +165,30 @@ namespace UAKino.Controllers
|
||||
return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
|
||||
@ -440,9 +440,30 @@ namespace UaTUT
|
||||
return OnError();
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
|
||||
@ -336,7 +336,10 @@ namespace Uaflix.Controllers
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = accsArgs(streamLink);
|
||||
string link = StripLampacArgs(streamLink?.Trim());
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
@ -350,5 +353,21 @@ namespace Uaflix.Controllers
|
||||
|
||||
return HostStreamProxy(init, link);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,7 +104,8 @@ namespace Unimay.Controllers
|
||||
if (string.IsNullOrEmpty(masterUrl))
|
||||
return OnError("no stream");
|
||||
|
||||
return UpdateService.Validate(Redirect(HostStreamProxy(init, accsArgs(masterUrl), proxy: proxyManager.Get())));
|
||||
string cleaned = StripLampacArgs(masterUrl?.Trim());
|
||||
return UpdateService.Validate(Redirect(HostStreamProxy(init, cleaned, proxy: proxyManager.Get())));
|
||||
}
|
||||
|
||||
if (itemType == "Фільм")
|
||||
@ -140,5 +141,21 @@ namespace Unimay.Controllers
|
||||
return OnError("unsupported type");
|
||||
});
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user