$theURI = urldecode($theURI);
// Need to check that the URI is fully decoded in case of multiple-encoded attack vectors.
$halt = 0;
while (true)
{
$last = $theURI;
$theURI = urldecode($theURI);
// Check whether the last decode is equal to the first.
if ($theURI == $last) {
// Break out of the while if the URI is stable.
break;
}
else if (++$halt > 10) {
// Runaway check. URI has been seriously compromised.
jexit();
}
}
// end Security Patch
$theURI = str_replace('"', '"',$theURI);
$theURI = str_replace('<', '<',$theURI);
$theURI = str_replace('>', '>',$theURI);
$theURI = preg_replace('/eval\((.*)\)/', '', $theURI);
$theURI = preg_replace('/[\\\"\\\'][\\s]*javascript

.*)[\\\"\\\']/', '""', $theURI);
}
else
{
// We were given a URI
$theURI = $uri;
}
// Create the new JURI instance