### Eclipse Workspace Patch 1.0
#P wordpress
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 16551)
+++ wp-includes/functions.php	(working copy)
@@ -4216,17 +4216,12 @@
  * @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 );
-
-	// PHP will close file handle, but we are good citizens.
-	fclose( $fp );
-
+	// build header filter based on default headers and context
 	if ( $context != '' ) {
-		$extra_headers = apply_filters( "extra_{$context}".'_headers', array() );
+		$extra_headers = apply_filters( "extra_{$context}_headers", array() );
 
 		$extra_headers = array_flip( $extra_headers );
 		foreach( $extra_headers as $key=>$value ) {
@@ -4237,18 +4232,69 @@
 		$all_headers = $default_headers;
 	}
 
+	// create return array with empty values
+	$return = array_keys( $all_headers );
+	if ( count( $return ) )
+		$return = array_combine( $return, array_fill( 0, count( $return ), '' ) );
 
-	foreach ( $all_headers as $field => $regex ) {
-		preg_match( '/^[\s\/*#]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, ${$field});
-		if ( !empty( ${$field} ) )
-			${$field} = _cleanup_header_comment( ${$field}[1] );
-		else
-			${$field} = '';
+	// 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] ); 
 	}
 
-	$file_data = compact( array_keys( $all_headers ) );
+	return $return;
+}
 
-	return $file_data;
+/**
+ * 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, normalized line-endings
+	if ( $fp = fopen( $file, 'r' ) ) {
+		$data = fread( $fp, 8192 );
+		fclose( $fp );
+		$data = str_replace( array ( "\r\n", "\r" ), "\n", $data ); // normalize line-endings		
+	}
+
+	$pstart = '^[ \t\/*#]*';
+
+	// single header, scrict as documented
+	// in http://codex.wordpress.org/File_Header#File_Header_Specification
+	$pheader = '([a-z]{3,12}(?: [a-z]{3,12}){0,2}):[ ]?(.+)'; 
+	
+	// instead, single header, more broad:
+	$pheader = '([a-z]+(?: [a-z]+)+):[ \t]*(.+)'; 
+
+	// extract headers block from data
+	$matches = array ();
+	$result  = preg_match( "/(({$pstart}({$pheader})\$)+)/mi", $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( "/{$pstart}{$pheader}\$/i", $line, $matches );
+		if ( $result ) {
+			list ( , $name, $value ) = $matches;
+			$header[$name] = $value;
+		}		
+	}
+
+	return $header;
 }
 
 /*
