# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
109c109,120
<       if (!$parts || !isset($parts['host'])) {
---
>       //code by ved start here validation
>       if(isset($parts['query']))
>   {
>   $youtube_id_old = substr($parts['query'],2);
>   $youtube_id_new = explode('&',$youtube_id_old);
>   $youtube_id = $youtube_id_new[0];
>  	$headers = get_headers('http://gdata.youtube.com/feeds/api/videos/' . $youtube_id);
>     }
>       
>       
>       //if (!$parts || !isset($parts['host'])) old if conditions
>       if (!$parts || !isset($parts['host']) || !isset($parts['query']) || !strpos($headers[0], '200')) {
128,139d138
<       
<       //Youtube specific check
<       if(stristr($item['video_url'], 'youtube.com')){
<         //Extract youtube video ID
<         parse_str(parse_url($item['video_url'], PHP_URL_QUERY), $urlparams);
<         if(isset($urlparams['v'])){
<           
<           $checkurl = 'http://gdata.youtube.com/feeds/api/videos/' . $urlparams['v'];
<           //Set an error handler for 400 warnings (Which the check url makes if it's an invalid YouTube video)
<           //set_error_handler('handleError');
<           try{
<             file_get_contents($checkurl);
141,145d139
<           catch (ErrorException $e){
<             $errors[$field['field_name']][$langcode][$delta][] = array(
<               'error' => t('Invalid youtube link, the video ID supplied in the link was invalid'), 
<               'message' => t('%name: The video ID supplied in the link was invalid.', array('%name' => $instance['label'])),
<             );
148,158d141
<         else{
<           $errors[$field['field_name']][$langcode][$delta][] = array(
<             'error' => t('Invalid youtube link, no youtube video ID was provided in the URL'), 
<             'message' => t('%name: No youtube video ID was provided in the URL.', array('%name' => $instance['label'])),
<           );
<         }
<       }
<       //http://www.youtube.com/watch?v=ysY9vwQQhCU
<     }
<   }
< }
161,173d143
<  * Custom error handler, for use with 400 warnings when validating YouTube URL
<  */
< function handleError($errno, $errstr, $errfile, $errline, array $errcontext){
< 
<     // error was suppressed with the @-operator
<     if (0 === error_reporting()) {
<         return false;
<     }
< 
<     throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
< }
< 
< /**
