### Eclipse Workspace Patch 1.0 #P librefm-trunk Index: nixtape/edit_profile.php =================================================================== --- nixtape/edit_profile.php (revision 941) +++ nixtape/edit_profile.php (working copy) @@ -23,6 +23,7 @@ require_once('templating.php'); require_once('data/User.php'); require_once('data/TagCloud.php'); +require_once('Validate.php'); if($logged_in == false) { @@ -41,32 +42,23 @@ { if (!empty($_POST['id'])) { - # Need better URI validation, but this will do for now. I think - # PEAR has a suitable module to help out here. - if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['id']) ) + if(!Validate::uri($_POST['id'])){ $errors[] = "WebID must be a URI."; - if ( preg_match('/\s/', $_POST['id']) ) - $errors[] = "WebID must be a URI. Valid URIs cannot contain whitespace."; + } } if (!empty($_POST['homepage'])) { - # Need better URI validation, but this will do for now. I think - # PEAR has a suitable module to help out here. - if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['homepage']) ) + if(!Validate::uri($_POST['id'])){ $errors[] = "Homepage must be a URI."; - if ( preg_match('/\s/', $_POST['homepage']) ) - $errors[] = "Homepage must be a URI. Valid URIs cannot contain whitespace."; + } } if (!empty($_POST['avatar_uri'])) { - # Need better URI validation, but this will do for now. I think - # PEAR has a suitable module to help out here. - if ( !preg_match('/^[a-z0-9\+\.\-]+\:/i', $_POST['avatar_uri']) ) + if(!Validate::uri($_POST['avatar_uri'])){ $errors[] = "Avatar must be a URI."; - if ( preg_match('/\s/', $_POST['avatar_uri']) ) - $errors[] = "Avatar must be a URI. Valid URIs cannot contain whitespace."; + } } if (!empty($_POST['password_1'])) @@ -76,7 +68,8 @@ } if (!empty($_POST['location_uri'])) - { + { + //TODO: Implement method from PEAR::Validate # Currently only allow geonames URIs, but there's no reason we can't accept # others at some point in the future. (e.g. dbpedia) if ( !preg_match('/^http:\/\/sws.geonames.org\/[0-9]+\/$/', $_POST['location_uri']) )