CodeIgniter Forums
validation prep_url patch - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: validation prep_url patch (/showthread.php?tid=10425)



validation prep_url patch - El Forum - 07-30-2008

[eluser]ReGeDa[/eluser]
i've patched it such as:
Code:
function prep_url($str = '')
{
    if ($str == 'http://' OR $str == '')
    {
        $_POST[$this->_current_field] = '';
        return;
    }
    
    //++ @PATCH
    
    if (! preg_match('/^((http|ftp)[s]?:\/{2}|mailto:)(.+)$/u',$str))
        $str = $str = 'http://'.$str;
        
    /*
    if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://')
    {
        $str = 'http://'.$str;
    }
    */
    //-- @PATCH
    
    $_POST[$this->_current_field] = $str;
}