### Eclipse Workspace Patch 1.0
#P wordpress-trunk
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 15087)
+++ wp-includes/functions.php	(working copy)
@@ -4158,40 +4158,77 @@
  * @param string $context If specified adds filter hook "extra_<$context>_headers"
  */
 function get_file_data( $file, $default_headers, $context = '' ) {
-	// We don't need to write to the file, so just open for reading.
-	$fp = fopen( $file, 'r' );
+	// retrieve all headers from file
+	$file_headers  = get_file_header( $file );
 
-	// Pull only the first 8kiB of the file in.
-	$file_data = fread( $fp, 8192 );
+	// build header filter based on default headers and context 
+	if ( empty ( $context ) ) {
+		$extra_headers = array ();		
+	} else {
+		$extra_headers = apply_filters( "extra_{$context}_headers", array () );
+		if ( count( $extra_headers ) && false === ($extra_headers = array_combine( $extra_headers, $extra_headers )) )  
+			$extra_headers = array (); // fallback in case of a plugin header name as key problem
+	}
+	$all_headers = array_merge( $extra_headers, $default_headers);
 
-	// PHP will close file handle, but we are good citizens.
-	fclose( $fp );
+	// create return array with empty values
+	$return = array_keys( $all_headers );
+	if ( count( $return ) )
+		$return = array_combine( $return, array_fill( 0, count( $return ), '') );
 
-	if ( $context != '' ) {
-		$extra_headers = apply_filters( "extra_$context".'_headers', array() );
+	// fill return array with header values
+	foreach ( $all_headers as $key => $name ) {
+		if ( isset( $file_headers[$name] ) )
+			$return[$key] = _cleanup_header_comment( $file_headers[$name] ); 
+	}
 
-		$extra_headers = array_flip( $extra_headers );
-		foreach( $extra_headers as $key=>$value ) {
-			$extra_headers[$key] = $key;
-		}
-		$all_headers = array_merge($extra_headers, $default_headers);
-	} else {
-		$all_headers = $default_headers;
+	return $return;
+}
+
+/**
+ * Retrieve headers from file
+ * 
+ * Get all of the file's file headers regardless of their name.
+ * 
+ * @date 2010-06-02
+ * @see http://codex.wordpress.org/File_Header
+ * @see http://core.trac.wordpress.org/attachment/ticket/13699
+ * 
+ * @param string $file Path to the file
+ * @return array all file header values keyed with their name
+ */
+function get_file_header( $file ) {
+	$data   = '';
+	$header = array ();
+
+	// read the first 8 192 bytes (8 kiB) from file
+	if ( $fp = fopen( $file, 'r' ) ) {
+		$data = fread( $fp, 8192 );
+		fclose( $fp );
+		$data    = str_replace( array ( "\r\n", "\r" ), "\n", $data ); // normalize line-endings		
 	}
 
+	$pheader = '([a-z]{3,12}( [a-z]{3,12}){0,2}):[ ]?(.*)'; // single header
 
-	foreach ( $all_headers as $field => $regex ) {
-		preg_match( '/' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
-		if ( !empty( ${$field} ) )
-			${$field} = _cleanup_header_comment( ${$field}[1] );
-		else
-			${$field} = '';
+	// extreact headers block from data	 	
+	$matches = array ();
+	$result  = preg_match( "/((.*({$pheader})\n)+)/i", $data, $matches );
+	$block   = $result ? trim( $matches[0] ) : '';
+
+	// extract headers line by line
+	$lines   = explode( "\n", $block );	
+	foreach ( $lines as $line ) {
+		$matches = array ();
+		$result  = preg_match( "/(^|\s){$pheader}\$/i", $line, $matches );
+		if ( $result ) {
+			list ( , , $name, , $value ) = $matches;
+			$header[$name]            = $value;
+		}		
 	}
 
-	$file_data = compact( array_keys( $all_headers ) );
+	return $header;
+}
 
-	return $file_data;
-}
 /*
  * Used internally to tidy up the search terms
  *
