mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Fixed blacklist check not just checking the hostname of the referer header
This commit is contained in:
parent
e901bbda6d
commit
8e22837158
@ -48,12 +48,22 @@ namespace Teknik.Middleware
|
||||
if (!blocked)
|
||||
{
|
||||
string referrer = context.Request.Headers["Referer"].ToString();
|
||||
string referrerHost = referrer;
|
||||
try
|
||||
{
|
||||
var referrerUri = new Uri(referrer);
|
||||
referrerHost = referrerUri.Host;
|
||||
} catch
|
||||
{ }
|
||||
if (!string.IsNullOrEmpty(referrer))
|
||||
{
|
||||
StringDictionary badReferrers = GetFileData(context, "BlockedReferrers", config.ReferrerBlacklistFile);
|
||||
|
||||
blocked |= (badReferrers != null && badReferrers.ContainsKey(referrer));
|
||||
blockReason = $"This referrer ({referrer}) has been blacklisted. If you feel this is in error, please contact support@teknik.io for assistance.";
|
||||
if (badReferrers != null)
|
||||
{
|
||||
blocked |= badReferrers.ContainsKey(referrer) || badReferrers.ContainsKey(referrerHost);
|
||||
blockReason = $"This referrer ({referrer}) has been blacklisted. If you feel this is in error, please contact support@teknik.io for assistance.";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user