I have a short url website where i only allow users to create short urls from one specific website. Some people have been trying to abuse this by using @ inbetween urls when shortening urls to make bad redirects. If you try let's say to enter "https://idg.se@stackoverflow.com" you will end up at stackoverflow and now idg.se. Try to paste "https://idg.se@stackoverflow.com" without the "" into your browser and se what happens.
So the problem is that people are now shortening "https://example.com@malware.com" and i want a way to stop this which would be not allowing the to use @.
Currently i have tried to copy my function for the valid url to check if there is an @ in there and currently i only end up "Invalid Character in the URL" whatever i am entering into the form to create a shorturl.
Anyone got any ideas how to get this to work? basically i do not want anyone to be able to use @.
FUNCTIONS
function DenySpeciallCharacters($url)
{
$strAllow2 = 'example.com';
$strBase2 = getBaseUrl($url);
if(preg_match('@', $url, $strAllow2) === false)
{
return true;
}
}
function denyNonValidUrl($url)
{
$strAllow = 'example.com';
$strBase = getBaseUrl($url);
if(strpos($url, $strAllow) === false)
{
return true;
}
}
INDEX FILE
if (!isErrors())
//do not allow non special characters
elseif(DenySpeciallCharacters($longUrl) )
{
setError("Invalid Character in the URL");
}